| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | " Vim syntax file | 
					
						
							|  |  |  | " Language:     Markdown | 
					
						
							|  |  |  | " Maintainer:   Tim Pope <vimNOSPAM@tpope.org> | 
					
						
							|  |  |  | " Filenames:    *.markdown | 
					
						
							| 
									
										
										
										
											2020-01-21 22:33:58 +01:00
										 |  |  | " Last Change:  2020 Jan 14 | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if exists("b:current_syntax") | 
					
						
							|  |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | if !exists('main_syntax') | 
					
						
							|  |  |  |   let main_syntax = 'markdown' | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | runtime! syntax/html.vim | 
					
						
							|  |  |  | unlet! b:current_syntax | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | if !exists('g:markdown_fenced_languages') | 
					
						
							|  |  |  |   let g:markdown_fenced_languages = [] | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | let s:done_include = {} | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")') | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   if has_key(s:done_include, matchstr(s:type,'[^.]*')) | 
					
						
							|  |  |  |     continue | 
					
						
							|  |  |  |   endif | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  |   if s:type =~ '\.' | 
					
						
							|  |  |  |     let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  |   exe 'syn include @markdownHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim' | 
					
						
							|  |  |  |   unlet! b:current_syntax | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   let s:done_include[matchstr(s:type,'[^.]*')] = 1 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | endfor | 
					
						
							|  |  |  | unlet! s:type | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | unlet! s:done_include | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | if !exists('g:markdown_minlines') | 
					
						
							|  |  |  |   let g:markdown_minlines = 50 | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | execute 'syn sync minlines=' . g:markdown_minlines | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | syn case ignore | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | syn match markdownValid '[<>]\c[a-z/$!]\@!' transparent contains=NONE | 
					
						
							|  |  |  | syn match markdownValid '&\%(#\=\w*;\)\@!' transparent contains=NONE | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock,htmlSpecialChar | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError,markdownValid | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn match markdownH1 "^.\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink | 
					
						
							|  |  |  | syn match markdownH2 "^.\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn match markdownHeadingRule "^[=-]\+$" contained | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | syn region markdownH1 matchgroup=markdownH1Delimiter start="##\@!"      end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained | 
					
						
							|  |  |  | syn region markdownH2 matchgroup=markdownH2Delimiter start="###\@!"     end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained | 
					
						
							|  |  |  | syn region markdownH3 matchgroup=markdownH3Delimiter start="####\@!"    end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained | 
					
						
							|  |  |  | syn region markdownH4 matchgroup=markdownH4Delimiter start="#####\@!"   end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained | 
					
						
							|  |  |  | syn region markdownH5 matchgroup=markdownH5Delimiter start="######\@!"  end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained | 
					
						
							|  |  |  | syn region markdownH6 matchgroup=markdownH6Delimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn match markdownBlockquote ">\%(\s\|$\)" contained nextgroup=@markdownBlock | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn region markdownCodeBlock start="    \|\t" end="$" contained | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " TODO: real nesting | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained | 
					
						
							|  |  |  | syn match markdownOrderedListMarker "\%(\t\| \{0,4}\)\<\d\+\.\%(\s\+\S\)\@=" contained | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn match markdownRule "\* *\* *\*[ *]*$" contained | 
					
						
							|  |  |  | syn match markdownRule "- *- *-[ -]*$" contained | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn match markdownLineBreak " \{2,\}$" | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite | 
					
						
							|  |  |  | syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained | 
					
						
							|  |  |  | syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained | 
					
						
							|  |  |  | syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained | 
					
						
							|  |  |  | syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained | 
					
						
							|  |  |  | syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\%(\_[^][]\|\[\_[^][]*\]\)*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained | 
					
						
							|  |  |  | syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained | 
					
						
							|  |  |  | syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | let s:concealends = '' | 
					
						
							|  |  |  | if has('conceal') && get(g:, 'markdown_syntax_conceal', 1) == 1 | 
					
						
							|  |  |  |   let s:concealends = ' concealends' | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2020-01-21 22:33:58 +01:00
										 |  |  | exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" skip="\\\*" contains=markdownLineStart,@Spell' . s:concealends | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\w\@<!_\S\@=" end="\S\@<=_\w\@!" skip="\\_" contains=markdownLineStart,@Spell' . s:concealends | 
					
						
							| 
									
										
										
										
											2020-01-21 22:33:58 +01:00
										 |  |  | exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" skip="\\\*" contains=markdownLineStart,markdownItalic,@Spell' . s:concealends | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\w\@<!__\S\@=" end="\S\@<=__\w\@!" skip="\\_" contains=markdownLineStart,markdownItalic,@Spell' . s:concealends | 
					
						
							| 
									
										
										
										
											2020-01-21 22:33:58 +01:00
										 |  |  | exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" skip="\\\*" contains=markdownLineStart,@Spell' . s:concealends | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\w\@<!___\S\@=" end="\S\@<=___\w\@!" skip="\\_" contains=markdownLineStart,@Spell' . s:concealends | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*````*.*$" end="^\s*````*\ze\s*$" keepend | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | syn match markdownFootnote "\[^[^\]]\+\]" | 
					
						
							|  |  |  | syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | if main_syntax ==# 'markdown' | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   let s:done_include = {} | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  |   for s:type in g:markdown_fenced_languages | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |     if has_key(s:done_include, matchstr(s:type,'[^.]*')) | 
					
						
							|  |  |  |       continue | 
					
						
							|  |  |  |     endif | 
					
						
							|  |  |  |     exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*````*\s*\%({.\{-}\.\)\='.matchstr(s:type,'[^=]*').'}\=\S\@!.*$" end="^\s*````*\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') . s:concealends | 
					
						
							|  |  |  |     let s:done_include[matchstr(s:type,'[^.]*')] = 1 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  |   endfor | 
					
						
							|  |  |  |   unlet! s:type | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  |   unlet! s:done_include | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | endif | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]" | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | syn match markdownError "\w\@<=_\w\@=" | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | hi def link markdownH1                    htmlH1 | 
					
						
							|  |  |  | hi def link markdownH2                    htmlH2 | 
					
						
							|  |  |  | hi def link markdownH3                    htmlH3 | 
					
						
							|  |  |  | hi def link markdownH4                    htmlH4 | 
					
						
							|  |  |  | hi def link markdownH5                    htmlH5 | 
					
						
							|  |  |  | hi def link markdownH6                    htmlH6 | 
					
						
							|  |  |  | hi def link markdownHeadingRule           markdownRule | 
					
						
							| 
									
										
										
										
											2019-12-05 22:47:25 +01:00
										 |  |  | hi def link markdownH1Delimiter           markdownHeadingDelimiter | 
					
						
							|  |  |  | hi def link markdownH2Delimiter           markdownHeadingDelimiter | 
					
						
							|  |  |  | hi def link markdownH3Delimiter           markdownHeadingDelimiter | 
					
						
							|  |  |  | hi def link markdownH4Delimiter           markdownHeadingDelimiter | 
					
						
							|  |  |  | hi def link markdownH5Delimiter           markdownHeadingDelimiter | 
					
						
							|  |  |  | hi def link markdownH6Delimiter           markdownHeadingDelimiter | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | hi def link markdownHeadingDelimiter      Delimiter | 
					
						
							|  |  |  | hi def link markdownOrderedListMarker     markdownListMarker | 
					
						
							|  |  |  | hi def link markdownListMarker            htmlTagName | 
					
						
							|  |  |  | hi def link markdownBlockquote            Comment | 
					
						
							|  |  |  | hi def link markdownRule                  PreProc | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | hi def link markdownFootnote              Typedef | 
					
						
							|  |  |  | hi def link markdownFootnoteDefinition    Typedef | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | hi def link markdownLinkText              htmlLink | 
					
						
							|  |  |  | hi def link markdownIdDeclaration         Typedef | 
					
						
							|  |  |  | hi def link markdownId                    Type | 
					
						
							|  |  |  | hi def link markdownAutomaticLink         markdownUrl | 
					
						
							|  |  |  | hi def link markdownUrl                   Float | 
					
						
							|  |  |  | hi def link markdownUrlTitle              String | 
					
						
							|  |  |  | hi def link markdownIdDelimiter           markdownLinkDelimiter | 
					
						
							|  |  |  | hi def link markdownUrlDelimiter          htmlTag | 
					
						
							|  |  |  | hi def link markdownUrlTitleDelimiter     Delimiter | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | hi def link markdownItalic                htmlItalic | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | hi def link markdownItalicDelimiter       markdownItalic | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | hi def link markdownBold                  htmlBold | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | hi def link markdownBoldDelimiter         markdownBold | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | hi def link markdownBoldItalic            htmlBoldItalic | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | hi def link markdownBoldItalicDelimiter   markdownBoldItalic | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | hi def link markdownCodeDelimiter         Delimiter | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | hi def link markdownEscape                Special | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | hi def link markdownError                 Error | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | let b:current_syntax = "markdown" | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | if main_syntax ==# 'markdown' | 
					
						
							|  |  |  |   unlet main_syntax | 
					
						
							|  |  |  | endif | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | " vim:set sw=2: |