Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9d38f69

Browse files
committedMay 12, 2020
chore: Gut current syntax to legacy mode, make way for CommonMark
1 parent 8e67ec8 commit 9d38f69

File tree

3 files changed

+612
-605
lines changed

3 files changed

+612
-605
lines changed
 

‎syntax/pandoc.vim

Lines changed: 13 additions & 605 deletions
Original file line numberDiff line numberDiff line change
@@ -1,615 +1,23 @@
1-
scriptencoding utf-8
2-
" vim: set fdm=marker foldlevel=0:
3-
"
41
" Vim syntax file
5-
"
6-
" Language: Pandoc (superset of Markdown)
2+
" Filetype: pandoc
3+
" Language: CommonMark
4+
" Maintainer: Caleb Maclennan <caleb@alerque.com>
75
" Maintainer: Felipe Morales <hel.sheep@gmail.com>
8-
" Contributor: David Sanson <dsanson@gmail.com>
9-
" Contributor: Jorge Israel Peña <jorge.israel.p@gmail.com>
10-
" OriginalAuthor: Jeremy Schultz <taozhyn@gmail.com>
11-
" Version: 5.0
12-
13-
" Configuration: {{{1
14-
"
15-
" use conceal? {{{2
16-
if !exists("g:pandoc#syntax#conceal#use")
17-
if v:version < 703
18-
let g:pandoc#syntax#conceal#use = 0
19-
else
20-
let g:pandoc#syntax#conceal#use = 1
21-
endif
22-
else
23-
" exists, but we cannot use it, disable anyway
24-
if v:version < 703
25-
let g:pandoc#syntax#conceal#use = 0
26-
endif
27-
endif
28-
"}}}2
29-
" what groups not to use conceal in. works as a blacklist {{{2
30-
if !exists("g:pandoc#syntax#conceal#blacklist")
31-
let g:pandoc#syntax#conceal#blacklist = []
32-
endif
33-
"}}}2
34-
" cchars used in conceal rules {{{2
35-
" utf-8 defaults (preferred)
36-
if &encoding == "utf-8"
37-
let s:cchars = {
38-
\"newline": "",
39-
\"image": "",
40-
\"super": "",
41-
\"sub": "",
42-
\"strike": "x̶",
43-
\"atx": "§",
44-
\"codelang": "λ",
45-
\"codeend": "",
46-
\"abbrev": "",
47-
\"footnote": "",
48-
\"definition": " ",
49-
\"li": "",
50-
\"html_c_s": "",
51-
\"html_c_e": ""}
52-
else
53-
" ascii defaults
54-
let s:cchars = {
55-
\"newline": " ",
56-
\"image": "i",
57-
\"super": "^",
58-
\"sub": "_",
59-
\"strike": "~",
60-
\"atx": "#",
61-
\"codelang": "l",
62-
\"codelang": "-",
63-
\"abbrev": "a",
64-
\"footnote": "f",
65-
\"definition": " ",
66-
\"li": "*",
67-
\"html_c_s": "+",
68-
\"html_c_e": "+"}
69-
endif
70-
"}}}2
71-
" if the user has a dictionary with replacements for the default cchars, use those {{{2
72-
if exists("g:pandoc#syntax#conceal#cchar_overrides")
73-
let s:cchars = extend(s:cchars, g:pandoc#syntax#conceal#cchar_overrides)
74-
endif
75-
"}}}2
76-
"should the urls in links be concealed? {{{2
77-
if !exists("g:pandoc#syntax#conceal#urls")
78-
let g:pandoc#syntax#conceal#urls = 0
79-
endif
80-
" should backslashes in escapes be concealed? {{{2
81-
if !exists("g:pandoc#syntax#conceal#backslash")
82-
let g:pandoc#syntax#conceal#backslash = 0
83-
endif
84-
"}}}2
85-
" leave specified codeblocks as Normal (i.e. 'unhighlighted') {{{2
86-
if !exists("g:pandoc#syntax#codeblocks#ignore")
87-
let g:pandoc#syntax#codeblocks#ignore = []
88-
endif
89-
"}}}2
90-
" use embedded highlighting for delimited codeblocks where a language is specifed. {{{2
91-
if !exists("g:pandoc#syntax#codeblocks#embeds#use")
92-
let g:pandoc#syntax#codeblocks#embeds#use = 1
93-
endif
94-
"}}}2
95-
" for what languages and using what vim syntax files highlight those embeds. {{{2
96-
" defaults to None.
97-
if !exists("g:pandoc#syntax#codeblocks#embeds#langs")
98-
let g:pandoc#syntax#codeblocks#embeds#langs = []
99-
endif
100-
"}}}2
101-
" use italics ? {{{2
102-
if !exists("g:pandoc#syntax#style#emphases")
103-
let g:pandoc#syntax#style#emphases = 1
104-
endif
105-
" if 0, we don't conceal the emphasis marks, otherwise there wouldn't be a way
106-
" to tell where the styles apply.
107-
if g:pandoc#syntax#style#emphases == 0
108-
call add(g:pandoc#syntax#conceal#blacklist, "block")
109-
endif
110-
" }}}2
111-
" underline subscript, superscript and strikeout? {{{2
112-
if !exists("g:pandoc#syntax#style#underline_special")
113-
let g:pandoc#syntax#style#underline_special = 1
114-
endif
115-
" }}}2
116-
" protect code blocks? {{{2
117-
if !exists("g:pandoc#syntax#protect#codeblocks")
118-
let g:pandoc#syntax#protect#codeblocks = 1
119-
endif
120-
" use color column? {{{2
121-
if !exists("g:pandoc#syntax#colorcolumn")
122-
let g:pandoc#syntax#colorcolumn = 0
123-
endif
124-
" }}}2
125-
" highlight new lines? {{{2
126-
if !exists("g:pandoc#syntax#newlines")
127-
let g:pandoc#syntax#newlines = 1
128-
endif
129-
" }}}
130-
" detect roman-numeral list items? {{{2
131-
if !exists('g:pandoc#syntax#roman_lists')
132-
let g:pandoc#syntax#roman_lists = 0
133-
endif
134-
" }}}
135-
"}}}1
136-
137-
" Functions: {{{1
138-
" EnableEmbedsforCodeblocksWithLang {{{2
139-
function! EnableEmbedsforCodeblocksWithLang(entry)
140-
try
141-
let s:langname = matchstr(a:entry, "^[^=]*")
142-
let s:langsyntaxfile = matchstr(a:entry, "[^=]*$")
143-
unlet! b:current_syntax
144-
exe 'syn include @'.toupper(s:langname).' syntax/'.s:langsyntaxfile.'.vim'
145-
exe "syn region pandocDelimitedCodeBlock_" . s:langname . ' start=/\(\_^\(\s\{4,}\)\=\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>.*\n\)\@<=\_^/' .
146-
\' end=/\_$\n\(\(\s\{4,}\)\=\(`\{3,}`*\|\~\{3,}\~*\)\_$\n\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock' .
147-
\' contains=@' . toupper(s:langname)
148-
exe "syn region pandocDelimitedCodeBlockinBlockQuote_" . s:langname . ' start=/>\s\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>/' .
149-
\ ' end=/\(`\{3,}`*\|\~\{3,}\~*\)/ contained containedin=pandocDelimitedCodeBlock' .
150-
\' contains=@' . toupper(s:langname) .
151-
\",pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd,pandodDelimitedCodeblockLang,pandocBlockQuoteinDelimitedCodeBlock"
152-
catch /E484/
153-
echo "No syntax file found for '" . s:langsyntaxfile . "'"
154-
endtry
155-
endfunction
156-
"}}}2
157-
" DisableEmbedsforCodeblocksWithLang {{{2
158-
function! DisableEmbedsforCodeblocksWithLang(langname)
159-
try
160-
exe 'syn clear pandocDelimitedCodeBlock_'.a:langname
161-
exe 'syn clear pandocDelimitedCodeBlockinBlockQuote_'.a:langname
162-
catch /E28/
163-
echo "No existing highlight definitions found for '" . a:langname . "'"
164-
endtry
165-
endfunction
166-
"}}}2
167-
" WithConceal {{{2
168-
function! s:WithConceal(rule_group, rule, conceal_rule)
169-
let l:rule_tail = ""
170-
if g:pandoc#syntax#conceal#use != 0
171-
if index(g:pandoc#syntax#conceal#blacklist, a:rule_group) == -1
172-
let l:rule_tail = " " . a:conceal_rule
173-
endif
174-
endif
175-
execute a:rule . l:rule_tail
176-
endfunction
177-
"}}}2
178-
"}}}1
179-
180-
" Commands: {{{1
181-
command! -buffer -nargs=1 -complete=syntax PandocHighlight call EnableEmbedsforCodeblocksWithLang(<f-args>)
182-
command! -buffer -nargs=1 -complete=syntax PandocUnhighlight call DisableEmbedsforCodeblocksWithLang(<f-args>)
183-
" }}}
184-
185-
" BASE:
186-
syntax clear
187-
syntax spell toplevel
188-
" apply extra settings: {{{1
189-
if g:pandoc#syntax#colorcolumn == 1
190-
exe "setlocal colorcolumn=".string(&textwidth+5)
191-
elseif g:pandoc#syntax#colorcolumn == 2
192-
exe "setlocal colorcolumn=".join(range(&textwidth+5, 2*&columns), ',')
193-
endif
194-
if g:pandoc#syntax#conceal#use != 0
195-
setlocal conceallevel=2
196-
endif
197-
"}}}1
198-
199-
" Syntax Rules: {{{1
200-
" Embeds: {{{2
201-
" HTML: {{{3
202-
" Set embedded HTML highlighting
203-
syn include @HTML syntax/html.vim
204-
syn match pandocHTML /<\/\?\a.\{-}>/ contains=@HTML
205-
" Support HTML multi line comments
206-
syn region pandocHTMLComment start=/<!--\s\=/ end=/\s\=-->/ keepend contains=pandocHTMLCommentStart,pandocHTMLCommentEnd
207-
call s:WithConceal('html_c_s', 'syn match pandocHTMLCommentStart /<!--/ contained', 'conceal cchar='.s:cchars['html_c_s'])
208-
call s:WithConceal('html_c_e', 'syn match pandocHTMLCommentEnd /-->/ contained', 'conceal cchar='.s:cchars['html_c_e'])
209-
" }}}
210-
" LaTeX: {{{3
211-
" Set embedded LaTex (pandoc extension) highlighting
212-
" Unset current_syntax so the 2nd include will work
213-
unlet b:current_syntax
214-
syn include @LATEX syntax/tex.vim
215-
syn region pandocLaTeXInlineMath start=/\\\@<!\$[[:graph:]]\@=/ end=/\\\@<!\$/ keepend contains=@LATEX
216-
syn region pandocLaTeXInlineMath start=/\\\@<!\\([[:graph:]]\@=/ end=/\\\@<!\\)/ keepend contains=@LATEX
217-
syn match pandocProtectedFromInlineLaTeX /\\\@<!\${.*}\(\(\s\|[[:punct:]]\)\([^$]*\|.*\(\\\$.*\)\{2}\)\n\n\|$\)\@=/ display
218-
" contains=@LATEX
219-
syn region pandocLaTeXMathBlock start=/\$\$/ end=/\$\$/ keepend contains=@LATEX
220-
syn match pandocLaTeXCommand /\\[[:alpha:]]\+\(\({.\{-}}\)\=\(\[.\{-}\]\)\=\)*/ contains=@LATEX
221-
syn region pandocLaTeXRegion start=/\\begin{\z(.\{-}\)}/ end=/\\end{\z1}/ keepend contains=@LATEX
222-
" we rehighlight sectioning commands, because otherwise tex.vim captures all text until EOF or a new sectioning command
223-
syn region pandocLaTexSection start=/\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)\*\=\(\[.*\]\)\={/ end=/\}/ keepend
224-
syn match pandocLaTexSectionCmd /\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)/ contained containedin=pandocLaTexSection
225-
syn match pandocLaTeXDelimiter /[[\]{}]/ contained containedin=pandocLaTexSection
226-
" }}}}
227-
" }}}2
228-
" Titleblock: {{{2
229-
"
230-
syn region pandocTitleBlock start=/\%^%/ end=/\n\n/ contains=pandocReferenceLabel,pandocReferenceURL,pandocNewLine
231-
call s:WithConceal("titleblock", 'syn match pandocTitleBlockMark /%\ / contained containedin=pandocTitleBlock,pandocTitleBlockTitle', 'conceal')
232-
syn match pandocTitleBlockTitle /\%^%.*\n/ contained containedin=pandocTitleBlock
233-
"}}}
234-
" Blockquotes: {{{2
235-
"
236-
syn match pandocBlockQuote /^\s\{,3}>.*\n\(.*\n\@1<!\n\)*/ contains=@Spell,pandocEmphasis,pandocStrong,pandocPCite,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocUListItem,pandocNoFormatted skipnl
237-
syn match pandocBlockQuoteMark /\_^\s\{,3}>/ contained containedin=pandocEmphasis,pandocStrong,pandocPCite,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocUListItem,pandocNoFormatted
238-
239-
" }}}
240-
" Code Blocks: {{{2
241-
if g:pandoc#syntax#protect#codeblocks == 1
242-
syn match pandocCodeblock /\s\{4}.*$/
243-
endif
244-
syn region pandocCodeBlockInsideIndent start=/\(\(\d\|\a\|*\).*\n\)\@<!\(^\(\s\{8,}\|\t\+\)\).*\n/ end=/.\(\n^\s*\n\)\@=/ contained
245-
"}}}
246-
" Links: {{{2
247-
"
248-
" Base: {{{3
249-
syn region pandocReferenceLabel matchgroup=Operator start=/!\{,1}\\\@<!\[/ skip=/\(\\\@<!\]\]\@=\|`.*\\\@<!].*`\)/ end=/\\\@<!\]/ keepend display
250-
if g:pandoc#syntax#conceal#urls == 1
251-
syn region pandocReferenceURL matchgroup=Operator start=/\]\@1<=(/ end=/)/ keepend display conceal
252-
else
253-
syn region pandocReferenceURL matchgroup=Operator start=/\]\@1<=(/ end=/)/ keepend display
254-
endif
255-
" let's not consider "a [label] a" as a label, remove formatting - Note: breaks implicit links
256-
syn match pandocNoLabel /\]\@1<!\(\s\{,3}\|^\)\[[^\[\]]\{-}\]\(\s\+\|$\)[\[(]\@!/ contains=pandocPCite
257-
syn match pandocLinkTip /\s*".\{-}"/ contained containedin=pandocReferenceURL contains=@Spell display
258-
call s:WithConceal("image", 'syn match pandocImageIcon /!\[\@=/ display', 'conceal cchar='. s:cchars["image"])
259-
" }}}
260-
" Definitions: {{{3
261-
syn region pandocReferenceDefinition start=/\[.\{-}\]:/ end=/\(\n\s*".*"$\|$\)/ keepend
262-
syn match pandocReferenceDefinitionLabel /\[\zs.\{-}\ze\]:/ contained containedin=pandocReferenceDefinition display
263-
syn match pandocReferenceDefinitionAddress /:\s*\zs.*/ contained containedin=pandocReferenceDefinition
264-
syn match pandocReferenceDefinitionTip /\s*".\{-}"/ contained containedin=pandocReferenceDefinition,pandocReferenceDefinitionAddress contains=@Spell
265-
"}}}
266-
" Automatic_links: {{{3
267-
syn match pandocAutomaticLink /<\(https\{0,1}.\{-}\|.\{-}@.\{-}\..\{-}\)>/ contains=NONE
268-
" }}}
269-
"}}}
270-
" Citations: {{{2
271-
" parenthetical citations
272-
syn match pandocPCite /\[.\{-}-\{0,1}@.\{-}\]/ contains=pandocEmphasis,pandocStrong,pandocLatex,pandocCiteKey,@Spell display
273-
" in-text citations with location
274-
syn match pandocICite /@[[:graph:]äëïöüáéíóúàèìòùłßÄËÏÖÜÁÉÍÓÚÀÈÌÒÙŁß]*\s\[.\{-}\]/ contains=pandocCiteKey,@Spell display
275-
" cite keys
276-
syn match pandocCiteKey /\(-\=@[[:graph:]äëïöüáéíóúàèìòùłßÄËÏÖÜÁÉÍÓÚÀÈÌÒÙŁß]*\)\(\]\|\>\)\@=/ containedin=pandocPCite,pandocICite contains=@NoSpell display
277-
syn match pandocCiteAnchor /[-@]/ contained containedin=pandocCiteKey display
278-
syn match pandocCiteLocator /[\[\]]/ contained containedin=pandocPCite,pandocICite
279-
" }}}
280-
" Text Styles: {{{2
281-
282-
" Emphasis: {{{3
283-
"
284-
call s:WithConceal("block", 'syn region pandocEmphasis matchgroup=Operator start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\*\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell,pandocNoFormattedInEmphasis,pandocLatexInlineMath', 'concealends')
285-
call s:WithConceal("block", 'syn region pandocEmphasis matchgroup=Operator start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@1<=_\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell,pandocNoFormattedInEmphasis,pandocLatexInlineMath', 'concealends')
286-
" }}}
287-
" Strong: {{{3
288-
"
289-
call s:WithConceal("block", 'syn region pandocStrong matchgroup=Operator start=/\(\\\@<!\*\)\{2}/ end=/\(\\\@<!\*\)\{2}/ contains=@Spell,pandocNoFormattedInStrong,pandocLatexInlineMath', 'concealends')
290-
call s:WithConceal("block", 'syn region pandocStrong matchgroup=Operator start=/__/ end=/__/ contains=@Spell,pandocNoFormattedInStrong,pandocLatexInlineMath', 'concealends')
291-
"}}}
292-
" Strong Emphasis: {{{3
293-
"
294-
call s:WithConceal("block", 'syn region pandocStrongEmphasis matchgroup=Operator start=/\*\{3}\(\S[^*]*\(\*\S\|\n[^*]*\*\S\)\)\@=/ end=/\S\@<=\*\{3}/ contains=@Spell', 'concealends')
295-
call s:WithConceal("block", 'syn region pandocStrongEmphasis matchgroup=Operator start=/\(___\)\S\@=/ end=/\S\@<=___/ contains=@Spell', 'concealends')
296-
" }}}
297-
" Mixed: {{{3
298-
call s:WithConceal("block", 'syn region pandocStrongInEmphasis matchgroup=Operator start=/\*\*/ end=/\*\*/ contained containedin=pandocEmphasis contains=@Spell', 'concealends')
299-
call s:WithConceal("block", 'syn region pandocStrongInEmphasis matchgroup=Operator start=/__/ end=/__/ contained containedin=pandocEmphasis contains=@Spell', 'concealends')
300-
call s:WithConceal("block", 'syn region pandocEmphasisInStrong matchgroup=Operator start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=\*\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=pandocStrong contains=@Spell', 'concealends')
301-
call s:WithConceal("block", 'syn region pandocEmphasisInStrong matchgroup=Operator start=/\\\@<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=_\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=pandocStrong contains=@Spell', 'concealends')
302-
303-
" Inline Code: {{{3
304-
305-
" Using single back ticks
306-
call s:WithConceal("inlinecode", 'syn region pandocNoFormatted matchgroup=Operator start=/\\\@<!`/ end=/\\\@<!`/ nextgroup=pandocNoFormattedAttrs', 'concealends')
307-
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInEmphasis matchgroup=Operator start=/\\\@<!`/ end=/\\\@<!`/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
308-
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInStrong matchgroup=Operator start=/\\\@<!`/ end=/\\\@<!`/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
309-
" Using double back ticks
310-
call s:WithConceal("inlinecode", 'syn region pandocNoFormatted matchgroup=Operator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs', 'concealends')
311-
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInEmphasis matchgroup=Operator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
312-
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInStrong matchgroup=Operator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
313-
syn match pandocNoFormattedAttrs /{.\{-}}/ contained
314-
"}}}
315-
" Subscripts: {{{3
316-
syn region pandocSubscript start=/\~\(\([[:graph:]]\(\\ \)\=\)\{-}\~\)\@=/ end=/\~/ keepend
317-
call s:WithConceal("subscript", 'syn match pandocSubscriptMark /\~/ contained containedin=pandocSubscript', 'conceal cchar='.s:cchars["sub"])
318-
"}}}
319-
" Superscript: {{{3
320-
syn region pandocSuperscript start=/\^\(\([[:graph:]]\(\\ \)\=\)\{-}\^\)\@=/ skip=/\\ / end=/\^/ keepend
321-
call s:WithConceal("superscript", 'syn match pandocSuperscriptMark /\^/ contained containedin=pandocSuperscript', 'conceal cchar='.s:cchars["super"])
322-
"}}}
323-
" Strikeout: {{{3
324-
syn region pandocStrikeout start=/\~\~/ end=/\~\~/ contains=@Spell keepend
325-
call s:WithConceal("strikeout", 'syn match pandocStrikeoutMark /\~\~/ contained containedin=pandocStrikeout', 'conceal cchar='.s:cchars["strike"])
326-
" }}}
327-
" }}}
328-
" Headers: {{{2
329-
"
330-
syn match pandocAtxHeader /\(\%^\|<.\+>.*\n\|^\s*\n\)\@<=#\{1,6}.*\n/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,@Spell, display
331-
syn match pandocAtxHeaderMark /\(^#\{1,6}\|\\\@<!#\+\(\s*.*$\)\@=\)/ contained containedin=pandocAtxHeader
332-
call s:WithConceal("atx", 'syn match pandocAtxStart /#/ contained containedin=pandocAtxHeaderMark', 'conceal cchar='.s:cchars["atx"])
333-
syn match pandocSetexHeader /^.\+\n[=]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,@Spell
334-
syn match pandocSetexHeader /^.\+\n[-]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,@Spell
335-
syn match pandocHeaderAttr /{.*}/ contained containedin=pandocAtxHeader,pandocSetexHeader
336-
syn match pandocHeaderID /#[-_:.[:alpha:]]*/ contained containedin=pandocHeaderAttr
337-
"}}}
338-
" Line Blocks: {{{2
339-
syn region pandocLineBlock start=/^|/ end=/\(^|\(.*\n|\@!\)\@=.*\)\@<=\n/ transparent
340-
syn match pandocLineBlockDelimiter /^|/ contained containedin=pandocLineBlock
341-
"}}}
342-
" Tables: {{{2
343-
344-
" Simple: {{{3
345-
346-
syn region pandocSimpleTable start=/\%#=2\(^.*[[:graph:]].*\n\)\@<!\(^.*[[:graph:]].*\n\)\(-\+\s*\)\+\n\n\@!/ end=/\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
347-
syn match pandocSimpleTableDelims /\-/ contained containedin=pandocSimpleTable
348-
syn match pandocSimpleTableHeader /\%#=2\(^.*[[:graph:]].*\n\)\@<!\(^.*[[:graph:]].*\n\)/ contained containedin=pandocSimpleTable
3496

350-
syn region pandocTable start=/\%#=2^\(-\+\s*\)\+\n\n\@!/ end=/\%#=2^\(-\+\s*\)\+\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
351-
syn match pandocTableDelims /\-/ contained containedin=pandocTable
352-
syn region pandocTableMultilineHeader start=/\%#=2\(^-\+\n\)\@<=./ end=/\%#=2\n-\@=/ contained containedin=pandocTable
353-
354-
" }}}3
355-
" Grid: {{{3
356-
syn region pandocGridTable start=/\%#=2\n\@1<=+-/ end=/+\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
357-
syn match pandocGridTableDelims /[\|=]/ contained containedin=pandocGridTable
358-
syn match pandocGridTableDelims /\%#=2\([\-+][\-+=]\@=\|[\-+=]\@1<=[\-+]\)/ contained containedin=pandocGridTable
359-
syn match pandocGridTableHeader /\%#=2\(^.*\n\)\(+=.*\)\@=/ contained containedin=pandocGridTable
360-
"}}}3
361-
" Pipe: {{{3
362-
" with beginning and end pipes
363-
syn region pandocPipeTable start=/\%#=2\([+|]\n\)\@<!\n\@1<=|\(.*|\)\@=/ end=/|.*\n\(\n\|{\)/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
364-
" without beginning and end pipes
365-
syn region pandocPipeTable start=/\%#=2^.*\n-.\{-}|/ end=/|.*\n\n/ keepend
366-
syn match pandocPipeTableDelims /[\|\-:+]/ contained containedin=pandocPipeTable
367-
syn match pandocPipeTableHeader /\(^.*\n\)\(|-\)\@=/ contained containedin=pandocPipeTable
368-
syn match pandocPipeTableHeader /\(^.*\n\)\(-\)\@=/ contained containedin=pandocPipeTable
369-
" }}}3
370-
syn match pandocTableHeaderWord /\<.\{-}\>/ contained containedin=pandocGridTableHeader,pandocPipeTableHeader
371-
" }}}2
372-
" Delimited Code Blocks: {{{2
373-
" this is here because we can override strikeouts and subscripts
374-
syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\(\s\{4,}\)\=\~\{3,}\~*\)/ end=/^\z1\~*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend
375-
syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\(\s\{4,}\)\=`\{3,}`*\)/ end=/^\z1`*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend
376-
call s:WithConceal("codeblock_start", 'syn match pandocDelimitedCodeBlockStart /\(\_^\n\_^\(>\s\)\?\(\s\{4,}\)\=\)\@<=\(\~\{3,}\~*\|`\{3,}`*\)/ contained containedin=pandocDelimitedCodeBlock nextgroup=pandocDelimitedCodeBlockLanguage', 'conceal cchar='.s:cchars["codelang"])
377-
syn match pandocDelimitedCodeBlockLanguage /\(\s\?\)\@<=.\+\(\_$\)\@=/ contained
378-
call s:WithConceal("codeblock_delim", 'syn match pandocDelimitedCodeBlockEnd /\(`\{3,}`*\|\~\{3,}\~*\)\(\_$\n\(>\s\)\?\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock', 'conceal cchar='.s:cchars["codeend"])
379-
syn match pandocBlockQuoteinDelimitedCodeBlock '^>' contained containedin=pandocDelimitedCodeBlock
380-
syn match pandocCodePre /<pre>.\{-}<\/pre>/ skipnl
381-
syn match pandocCodePre /<code>.\{-}<\/code>/ skipnl
382-
383-
" enable highlighting for embedded region in codeblocks if there exists a
384-
" g:pandoc#syntax#codeblocks#embeds#langs *list*.
385-
"
386-
" entries in this list are the language code interpreted by pandoc,
387-
" if this differs from the name of the vim syntax file, append =vimname
388-
" e.g. let g:pandoc#syntax#codeblocks#embeds#langs = ["haskell", "literatehaskell=lhaskell"]
389-
"
390-
if g:pandoc#syntax#codeblocks#embeds#use != 0
391-
for l in g:pandoc#syntax#codeblocks#embeds#langs
392-
call EnableEmbedsforCodeblocksWithLang(l)
393-
endfor
394-
endif
395-
" }}}
396-
" Abbreviations: {{{2
397-
syn region pandocAbbreviationDefinition start=/^\*\[.\{-}\]:\s*/ end="$" contains=pandocNoFormatted,@Spell
398-
call s:WithConceal('abbrev', 'syn match pandocAbbreviationSeparator /:/ contained containedin=pandocAbbreviationDefinition', "conceal cchar=".s:cchars["abbrev"])
399-
syn match pandocAbbreviation /\*\[.\{-}\]/ contained containedin=pandocAbbreviationDefinition
400-
call s:WithConceal('abbrev', 'syn match pandocAbbreviationHead /\*\[/ contained containedin=pandocAbbreviation', "conceal")
401-
call s:WithConceal('abbrev', 'syn match pandocAbbreviationTail /\]/ contained containedin=pandocAbbreviation', "conceal")
402-
" }}}
403-
" Footnotes: {{{2
404-
" we put these here not to interfere with superscripts.
405-
"
406-
syn match pandocFootnoteID /\[\^[^\]]\+\]/ nextgroup=pandocFootnoteDef
407-
" Inline footnotes
408-
syn region pandocFootnoteDef start=/\^\[/ end=/\]/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,,pandocEnDash,pandocEmDash,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell skipnl keepend
409-
call s:WithConceal("footnote", 'syn match pandocFootnoteDefHead /\^\[/ contained containedin=pandocFootnoteDef', 'conceal cchar='.s:cchars["footnote"])
410-
call s:WithConceal("footnote", 'syn match pandocFootnoteDefTail /\]/ contained containedin=pandocFootnoteDef', 'conceal')
411-
412-
" regular footnotes
413-
syn region pandocFootnoteBlock start=/\[\^.\{-}\]:\s*\n*/ end=/^\n^\s\@!/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocNewLine,pandocStrongEmphasis,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell skipnl
414-
syn match pandocFootnoteBlockSeparator /:/ contained containedin=pandocFootnoteBlock
415-
syn match pandocFootnoteID /\[\^.\{-}\]/ contained containedin=pandocFootnoteBlock
416-
call s:WithConceal("footnote", 'syn match pandocFootnoteIDHead /\[\^/ contained containedin=pandocFootnoteID', 'conceal cchar='.s:cchars["footnote"])
417-
call s:WithConceal("footnote", 'syn match pandocFootnoteIDTail /\]/ contained containedin=pandocFootnoteID', 'conceal')
418-
" }}}
419-
" List Items: {{{2
420-
"
421-
" Unordered lists
422-
syn match pandocUListItem /^>\=\s*[*+-]\s\+-\@!.*$/ nextgroup=pandocUListItem,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocReferenceURL,pandocAutomaticLink skipempty display
423-
call s:WithConceal('list', 'syn match pandocUListItemBullet /^>\=\s*\zs[*+-]/ contained containedin=pandocUListItem', 'conceal cchar='.s:cchars['li'])
424-
425-
" Ordered lists
426-
syn match pandocListItem /^\s*(\?\(\d\+\|\l\|\#\|@\)[.)].*$/ nextgroup=pandocListItem,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink skipempty display
427-
" support for roman numerals up to 'c'
428-
if g:pandoc#syntax#roman_lists != 0
429-
syn match pandocListItem /^\s*(\?x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}[.)].*$/ nextgroup=pandocListItem,pandocMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation,pandocAutomaticLink skipempty display
430-
endif
431-
syn match pandocListItemBullet /^(\?.\{-}[.)]/ contained containedin=pandocListItem
432-
syn match pandocListItemBulletId /\(\d\+\|\l\|\#\|@.\{-}\|x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}\)/ contained containedin=pandocListItemBullet
433-
434-
syn match pandocListItemContinuation /^\s\+\([-+*]\s\+\|(\?.\+[).]\)\@<!\([[:alpha:]ñäëïöüáéíóúàèìòùłßÄËÏÖÜÁÉÍÓÚÀÈÌÒÙŁß_"[]\|\*\S\)\@=.*$/ nextgroup=pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation,pandocListItem contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocReferenceURL,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink contained skipempty display
435-
" }}}
436-
" Definitions: {{{2
437-
"
438-
syn region pandocDefinitionBlock start=/^\%(\_^\s*\([`~]\)\1\{2,}\)\@!.*\n\(^\s*\n\)\=\s\{0,2}[:~]\(\~\{2,}\~*\)\@!/ skip=/\n\n\zs\s/ end=/\n\n/ contains=pandocDefinitionBlockMark,pandocDefinitionBlockTerm,pandocCodeBlockInsideIndent,pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocFootnoteID,pandocReferenceURL,pandocReferenceLabel,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink,pandocEmDash,pandocEnDash
439-
syn match pandocDefinitionBlockTerm /^.*\n\(^\s*\n\)\=\(\s*[:~]\)\@=/ contained contains=pandocNoFormatted,pandocEmphasis,pandocStrong,pandocLaTeXInlineMath nextgroup=pandocDefinitionBlockMark
440-
call s:WithConceal("definition", 'syn match pandocDefinitionBlockMark /^\s*[:~]/ contained', 'conceal cchar='.s:cchars["definition"])
441-
" }}}
442-
" Special: {{{2
443-
444-
" New_lines: {{{3
445-
if g:pandoc#syntax#newlines == 1
446-
call s:WithConceal("newline", 'syn match pandocNewLine /\( \|\\\)$/ display containedin=pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocStrongInEmphasis,pandocEmphasisInStrong', 'conceal cchar='.s:cchars["newline"])
447-
endif
448-
"}}}
449-
" Emdashes: {{{3
450-
if &encoding == "utf-8"
451-
call s:WithConceal("emdashes", 'syn match pandocEllipses /\([^-]\)\@<=---\([^-]\)\@=/ display', 'conceal cchar=—')
452-
endif
453-
" }}}
454-
" Endashes: {{{3
455-
if &encoding == "utf-8"
456-
call s:WithConceal("endashes", 'syn match pandocEllipses /\([^-]\)\@<=--\([^-]\)\@=/ display', 'conceal cchar=–')
457-
endif
458-
" }}}
459-
" Ellipses: {{{3
460-
if &encoding == "utf-8"
461-
call s:WithConceal("ellipses", 'syn match pandocEllipses /\.\.\./ display', 'conceal cchar=…')
462-
endif
463-
" }}}
464-
" Quotes: {{{3
465-
if &encoding == "utf-8"
466-
call s:WithConceal("quotes", 'syn match pandocBeginQuote /"\</ containedin=pandocEmphasis,pandocStrong,pandocListItem,pandocListItemContinuation,pandocUListItem display', 'conceal cchar=“')
467-
call s:WithConceal("quotes", 'syn match pandocEndQuote /\(\>[[:punct:]]*\)\@<="[[:blank:][:punct:]\n]\@=/ containedin=pandocEmphasis,pandocStrong,pandocUListItem,pandocListItem,pandocListItemContinuation display', 'conceal cchar=”')
468-
endif
469-
" Hrule: {{{3
470-
syn match pandocHRule /^\s*\([*\-_]\)\s*\%(\1\s*\)\{2,}$/ display
471-
" Backslashes: {{{3
472-
if g:pandoc#syntax#conceal#backslash == 1
473-
syn match pandocBackslash /\\\@<!\\/ containedin=ALLBUT,pandocCodeblock,pandocCodeBlockInsideIndent,pandocNoFormatted,pandocNoFormattedInEmphasis,pandocNoFormattedInStrong,pandocDelimitedCodeBlock,pandocLineBlock,pandocYAMLHeader conceal
474-
endif
475-
" }}}
476-
" }}}
477-
" YAML: {{{2
478-
479-
try
480-
unlet! b:current_syntax
481-
syn include @YAML syntax/yaml.vim
482-
catch /E484/
483-
endtry
484-
syn region pandocYAMLHeader start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=@YAML containedin=TOP
485-
"}}}
486-
"}}}1
487-
488-
" Styling: {{{1
489-
" override this for consistency
490-
hi pandocTitleBlock term=italic gui=italic
491-
hi link pandocTitleBlockTitle Directory
492-
hi link pandocAtxHeader Title
493-
hi link pandocAtxStart Operator
494-
hi link pandocSetexHeader Title
495-
hi link pandocHeaderAttr Comment
496-
hi link pandocHeaderID Identifier
497-
498-
hi link pandocLaTexSectionCmd texSection
499-
hi link pandocLaTeXDelimiter texDelimiter
500-
501-
hi link pandocHTMLComment Comment
502-
hi link pandocHTMLCommentStart Delimiter
503-
hi link pandocHTMLCommentEnd Delimiter
504-
hi link pandocBlockQuote Comment
505-
hi link pandocBlockQuoteMark Comment
506-
507-
" if the user sets g:pandoc#syntax#codeblocks#ignore to contain
508-
" a codeblock type, don't highlight it so that it remains Normal
7+
scriptencoding utf-8
5098

510-
if index(g:pandoc#syntax#codeblocks#ignore, 'definition') == -1
511-
hi link pandocCodeBlockInsideIndent String
9+
if exists('b:current_syntax')
10+
finish
51211
endif
51312

514-
if index(g:pandoc#syntax#codeblocks#ignore, 'delimited') == -1
515-
hi link pandocDelimitedCodeBlock Special
13+
if !exists('b:is_legacy')
14+
let b:is_legacy = exists('g:pandoc_legacy')
51615
endif
51716

518-
hi link pandocDelimitedCodeBlockStart Delimiter
519-
hi link pandocDelimitedCodeBlockEnd Delimiter
520-
hi link pandocDelimitedCodeBlockLanguage Comment
521-
hi link pandocBlockQuoteinDelimitedCodeBlock pandocBlockQuote
522-
hi link pandocCodePre String
523-
524-
hi link pandocLineBlockDelimiter Delimiter
525-
526-
hi link pandocListItemBullet Operator
527-
hi link pandocUListItemBullet Operator
528-
hi link pandocListItemBulletId Identifier
529-
530-
hi link pandocReferenceLabel Label
531-
hi link pandocReferenceURL Underlined
532-
hi link pandocLinkTip Identifier
533-
hi link pandocImageIcon Operator
534-
535-
hi link pandocReferenceDefinition Operator
536-
hi link pandocReferenceDefinitionLabel Label
537-
hi link pandocReferenceDefinitionAddress Underlined
538-
hi link pandocReferenceDefinitionTip Identifier
539-
540-
hi link pandocAutomaticLink Underlined
541-
542-
hi link pandocDefinitionBlockTerm Identifier
543-
hi link pandocDefinitionBlockMark Operator
544-
545-
hi link pandocSimpleTableDelims Delimiter
546-
hi link pandocSimpleTableHeader pandocStrong
547-
hi link pandocTableMultilineHeader pandocStrong
548-
hi link pandocTableDelims Delimiter
549-
hi link pandocGridTableDelims Delimiter
550-
hi link pandocGridTableHeader Delimiter
551-
hi link pandocPipeTableDelims Delimiter
552-
hi link pandocPipeTableHeader Delimiter
553-
hi link pandocTableHeaderWord pandocStrong
554-
555-
hi link pandocAbbreviationHead Type
556-
hi link pandocAbbreviation Label
557-
hi link pandocAbbreviationTail Type
558-
hi link pandocAbbreviationSeparator Identifier
559-
hi link pandocAbbreviationDefinition Comment
560-
561-
hi link pandocFootnoteID Label
562-
hi link pandocFootnoteIDHead Type
563-
hi link pandocFootnoteIDTail Type
564-
hi link pandocFootnoteDef Comment
565-
hi link pandocFootnoteDefHead Type
566-
hi link pandocFootnoteDefTail Type
567-
hi link pandocFootnoteBlock Comment
568-
hi link pandocFootnoteBlockSeparator Operator
569-
570-
hi link pandocPCite Normal
571-
hi link pandocICite Normal
572-
hi link pandocCiteKey Identifier
573-
hi link pandocCiteAnchor Operator
574-
hi link pandocCiteLocator Operator
575-
576-
if g:pandoc#syntax#style#emphases == 1
577-
hi pandocEmphasis gui=italic cterm=italic
578-
hi pandocStrong gui=bold cterm=bold
579-
hi pandocStrongEmphasis gui=bold,italic cterm=bold,italic
580-
hi pandocStrongInEmphasis gui=bold,italic cterm=bold,italic
581-
hi pandocEmphasisInStrong gui=bold,italic cterm=bold,italic
582-
if !exists('s:hi_tail')
583-
for s:i in ["fg", "bg"]
584-
let s:tmp_val = synIDattr(synIDtrans(hlID("String")), s:i)
585-
let s:tmp_ui = has('gui_running') || has('nvim') ? 'gui' : 'cterm'
586-
if !empty(s:tmp_val) && s:tmp_val != -1
587-
exe 'let s:'.s:i . ' = "'.s:tmp_ui.s:i.'='.s:tmp_val.'"'
588-
else
589-
exe 'let s:'.s:i . ' = ""'
590-
endif
591-
endfor
592-
let s:hi_tail = ' '.s:fg.' '.s:bg
593-
endif
594-
exe 'hi pandocNoFormattedInEmphasis gui=italic cterm=italic'.s:hi_tail
595-
exe 'hi pandocNoFormattedInStrong gui=bold cterm=bold'.s:hi_tail
596-
endif
597-
hi link pandocNoFormatted String
598-
hi link pandocNoFormattedAttrs Comment
599-
hi link pandocSubscriptMark Operator
600-
hi link pandocSuperscriptMark Operator
601-
hi link pandocStrikeoutMark Operator
602-
if g:pandoc#syntax#style#underline_special == 1
603-
hi pandocSubscript gui=underline cterm=underline
604-
hi pandocSuperscript gui=underline cterm=underline
605-
hi pandocStrikeout gui=underline cterm=underline
17+
if b:is_legacy
18+
runtime syntax/pandoc_legacy.vim
19+
else
20+
runtime syntax/pandoc_commonmark.vim
60621
endif
607-
hi link pandocNewLine Error
608-
hi link pandocHRule Delimiter
609-
610-
"}}}
611-
612-
let b:current_syntax = "pandoc"
61322

614-
syntax sync clear
615-
syntax sync minlines=100
23+
let b:current_syntax = b:is_legacy ? 'pandoc' : 'pandoc_legacy'

‎syntax/pandoc_commonmark.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
syntax clear

‎syntax/pandoc_legacy.vim

Lines changed: 598 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,598 @@
1+
if !exists("g:pandoc#syntax#conceal#use")
2+
if v:version < 703
3+
let g:pandoc#syntax#conceal#use = 0
4+
else
5+
let g:pandoc#syntax#conceal#use = 1
6+
endif
7+
else
8+
" exists, but we cannot use it, disable anyway
9+
if v:version < 703
10+
let g:pandoc#syntax#conceal#use = 0
11+
endif
12+
endif
13+
"}}}2
14+
" what groups not to use conceal in. works as a blacklist {{{2
15+
if !exists("g:pandoc#syntax#conceal#blacklist")
16+
let g:pandoc#syntax#conceal#blacklist = []
17+
endif
18+
"}}}2
19+
" cchars used in conceal rules {{{2
20+
" utf-8 defaults (preferred)
21+
if &encoding == "utf-8"
22+
let s:cchars = {
23+
\"newline": "",
24+
\"image": "",
25+
\"super": "",
26+
\"sub": "",
27+
\"strike": "x̶",
28+
\"atx": "§",
29+
\"codelang": "λ",
30+
\"codeend": "",
31+
\"abbrev": "",
32+
\"footnote": "",
33+
\"definition": " ",
34+
\"li": "",
35+
\"html_c_s": "",
36+
\"html_c_e": ""}
37+
else
38+
" ascii defaults
39+
let s:cchars = {
40+
\"newline": " ",
41+
\"image": "i",
42+
\"super": "^",
43+
\"sub": "_",
44+
\"strike": "~",
45+
\"atx": "#",
46+
\"codelang": "l",
47+
\"codelang": "-",
48+
\"abbrev": "a",
49+
\"footnote": "f",
50+
\"definition": " ",
51+
\"li": "*",
52+
\"html_c_s": "+",
53+
\"html_c_e": "+"}
54+
endif
55+
"}}}2
56+
" if the user has a dictionary with replacements for the default cchars, use those {{{2
57+
if exists("g:pandoc#syntax#conceal#cchar_overrides")
58+
let s:cchars = extend(s:cchars, g:pandoc#syntax#conceal#cchar_overrides)
59+
endif
60+
"}}}2
61+
"should the urls in links be concealed? {{{2
62+
if !exists("g:pandoc#syntax#conceal#urls")
63+
let g:pandoc#syntax#conceal#urls = 0
64+
endif
65+
" should backslashes in escapes be concealed? {{{2
66+
if !exists("g:pandoc#syntax#conceal#backslash")
67+
let g:pandoc#syntax#conceal#backslash = 0
68+
endif
69+
"}}}2
70+
" leave specified codeblocks as Normal (i.e. 'unhighlighted') {{{2
71+
if !exists("g:pandoc#syntax#codeblocks#ignore")
72+
let g:pandoc#syntax#codeblocks#ignore = []
73+
endif
74+
"}}}2
75+
" use embedded highlighting for delimited codeblocks where a language is specifed. {{{2
76+
if !exists("g:pandoc#syntax#codeblocks#embeds#use")
77+
let g:pandoc#syntax#codeblocks#embeds#use = 1
78+
endif
79+
"}}}2
80+
" for what languages and using what vim syntax files highlight those embeds. {{{2
81+
" defaults to None.
82+
if !exists("g:pandoc#syntax#codeblocks#embeds#langs")
83+
let g:pandoc#syntax#codeblocks#embeds#langs = []
84+
endif
85+
"}}}2
86+
" use italics ? {{{2
87+
if !exists("g:pandoc#syntax#style#emphases")
88+
let g:pandoc#syntax#style#emphases = 1
89+
endif
90+
" if 0, we don't conceal the emphasis marks, otherwise there wouldn't be a way
91+
" to tell where the styles apply.
92+
if g:pandoc#syntax#style#emphases == 0
93+
call add(g:pandoc#syntax#conceal#blacklist, "block")
94+
endif
95+
" }}}2
96+
" underline subscript, superscript and strikeout? {{{2
97+
if !exists("g:pandoc#syntax#style#underline_special")
98+
let g:pandoc#syntax#style#underline_special = 1
99+
endif
100+
" }}}2
101+
" protect code blocks? {{{2
102+
if !exists("g:pandoc#syntax#protect#codeblocks")
103+
let g:pandoc#syntax#protect#codeblocks = 1
104+
endif
105+
" use color column? {{{2
106+
if !exists("g:pandoc#syntax#colorcolumn")
107+
let g:pandoc#syntax#colorcolumn = 0
108+
endif
109+
" }}}2
110+
" highlight new lines? {{{2
111+
if !exists("g:pandoc#syntax#newlines")
112+
let g:pandoc#syntax#newlines = 1
113+
endif
114+
" }}}
115+
" detect roman-numeral list items? {{{2
116+
if !exists('g:pandoc#syntax#roman_lists')
117+
let g:pandoc#syntax#roman_lists = 0
118+
endif
119+
" }}}
120+
"}}}1
121+
122+
" Functions: {{{1
123+
" EnableEmbedsforCodeblocksWithLang {{{2
124+
function! EnableEmbedsforCodeblocksWithLang(entry)
125+
try
126+
let s:langname = matchstr(a:entry, "^[^=]*")
127+
let s:langsyntaxfile = matchstr(a:entry, "[^=]*$")
128+
unlet! b:current_syntax
129+
exe 'syn include @'.toupper(s:langname).' syntax/'.s:langsyntaxfile.'.vim'
130+
exe "syn region pandocDelimitedCodeBlock_" . s:langname . ' start=/\(\_^\(\s\{4,}\)\=\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>.*\n\)\@<=\_^/' .
131+
\' end=/\_$\n\(\(\s\{4,}\)\=\(`\{3,}`*\|\~\{3,}\~*\)\_$\n\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock' .
132+
\' contains=@' . toupper(s:langname)
133+
exe "syn region pandocDelimitedCodeBlockinBlockQuote_" . s:langname . ' start=/>\s\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>/' .
134+
\ ' end=/\(`\{3,}`*\|\~\{3,}\~*\)/ contained containedin=pandocDelimitedCodeBlock' .
135+
\' contains=@' . toupper(s:langname) .
136+
\",pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd,pandodDelimitedCodeblockLang,pandocBlockQuoteinDelimitedCodeBlock"
137+
catch /E484/
138+
echo "No syntax file found for '" . s:langsyntaxfile . "'"
139+
endtry
140+
endfunction
141+
"}}}2
142+
" DisableEmbedsforCodeblocksWithLang {{{2
143+
function! DisableEmbedsforCodeblocksWithLang(langname)
144+
try
145+
exe 'syn clear pandocDelimitedCodeBlock_'.a:langname
146+
exe 'syn clear pandocDelimitedCodeBlockinBlockQuote_'.a:langname
147+
catch /E28/
148+
echo "No existing highlight definitions found for '" . a:langname . "'"
149+
endtry
150+
endfunction
151+
"}}}2
152+
" WithConceal {{{2
153+
function! s:WithConceal(rule_group, rule, conceal_rule)
154+
let l:rule_tail = ""
155+
if g:pandoc#syntax#conceal#use != 0
156+
if index(g:pandoc#syntax#conceal#blacklist, a:rule_group) == -1
157+
let l:rule_tail = " " . a:conceal_rule
158+
endif
159+
endif
160+
execute a:rule . l:rule_tail
161+
endfunction
162+
"}}}2
163+
"}}}1
164+
165+
" Commands: {{{1
166+
command! -buffer -nargs=1 -complete=syntax PandocHighlight call EnableEmbedsforCodeblocksWithLang(<f-args>)
167+
command! -buffer -nargs=1 -complete=syntax PandocUnhighlight call DisableEmbedsforCodeblocksWithLang(<f-args>)
168+
" }}}
169+
170+
" BASE:
171+
syntax clear
172+
syntax spell toplevel
173+
" apply extra settings: {{{1
174+
if g:pandoc#syntax#colorcolumn == 1
175+
exe "setlocal colorcolumn=".string(&textwidth+5)
176+
elseif g:pandoc#syntax#colorcolumn == 2
177+
exe "setlocal colorcolumn=".join(range(&textwidth+5, 2*&columns), ',')
178+
endif
179+
if g:pandoc#syntax#conceal#use != 0
180+
setlocal conceallevel=2
181+
endif
182+
"}}}1
183+
184+
" Syntax Rules: {{{1
185+
" Embeds: {{{2
186+
" HTML: {{{3
187+
" Set embedded HTML highlighting
188+
syn include @HTML syntax/html.vim
189+
syn match pandocHTML /<\/\?\a.\{-}>/ contains=@HTML
190+
" Support HTML multi line comments
191+
syn region pandocHTMLComment start=/<!--\s\=/ end=/\s\=-->/ keepend contains=pandocHTMLCommentStart,pandocHTMLCommentEnd
192+
call s:WithConceal('html_c_s', 'syn match pandocHTMLCommentStart /<!--/ contained', 'conceal cchar='.s:cchars['html_c_s'])
193+
call s:WithConceal('html_c_e', 'syn match pandocHTMLCommentEnd /-->/ contained', 'conceal cchar='.s:cchars['html_c_e'])
194+
" }}}
195+
" LaTeX: {{{3
196+
" Set embedded LaTex (pandoc extension) highlighting
197+
" Unset current_syntax so the 2nd include will work
198+
unlet b:current_syntax
199+
syn include @LATEX syntax/tex.vim
200+
syn region pandocLaTeXInlineMath start=/\\\@<!\$[[:graph:]]\@=/ end=/\\\@<!\$/ keepend contains=@LATEX
201+
syn region pandocLaTeXInlineMath start=/\\\@<!\\([[:graph:]]\@=/ end=/\\\@<!\\)/ keepend contains=@LATEX
202+
syn match pandocProtectedFromInlineLaTeX /\\\@<!\${.*}\(\(\s\|[[:punct:]]\)\([^$]*\|.*\(\\\$.*\)\{2}\)\n\n\|$\)\@=/ display
203+
" contains=@LATEX
204+
syn region pandocLaTeXMathBlock start=/\$\$/ end=/\$\$/ keepend contains=@LATEX
205+
syn match pandocLaTeXCommand /\\[[:alpha:]]\+\(\({.\{-}}\)\=\(\[.\{-}\]\)\=\)*/ contains=@LATEX
206+
syn region pandocLaTeXRegion start=/\\begin{\z(.\{-}\)}/ end=/\\end{\z1}/ keepend contains=@LATEX
207+
" we rehighlight sectioning commands, because otherwise tex.vim captures all text until EOF or a new sectioning command
208+
syn region pandocLaTexSection start=/\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)\*\=\(\[.*\]\)\={/ end=/\}/ keepend
209+
syn match pandocLaTexSectionCmd /\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)/ contained containedin=pandocLaTexSection
210+
syn match pandocLaTeXDelimiter /[[\]{}]/ contained containedin=pandocLaTexSection
211+
" }}}}
212+
" }}}2
213+
" Titleblock: {{{2
214+
"
215+
syn region pandocTitleBlock start=/\%^%/ end=/\n\n/ contains=pandocReferenceLabel,pandocReferenceURL,pandocNewLine
216+
call s:WithConceal("titleblock", 'syn match pandocTitleBlockMark /%\ / contained containedin=pandocTitleBlock,pandocTitleBlockTitle', 'conceal')
217+
syn match pandocTitleBlockTitle /\%^%.*\n/ contained containedin=pandocTitleBlock
218+
"}}}
219+
" Blockquotes: {{{2
220+
"
221+
syn match pandocBlockQuote /^\s\{,3}>.*\n\(.*\n\@1<!\n\)*/ contains=@Spell,pandocEmphasis,pandocStrong,pandocPCite,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocUListItem,pandocNoFormatted skipnl
222+
syn match pandocBlockQuoteMark /\_^\s\{,3}>/ contained containedin=pandocEmphasis,pandocStrong,pandocPCite,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocUListItem,pandocNoFormatted
223+
224+
" }}}
225+
" Code Blocks: {{{2
226+
if g:pandoc#syntax#protect#codeblocks == 1
227+
syn match pandocCodeblock /\s\{4}.*$/
228+
endif
229+
syn region pandocCodeBlockInsideIndent start=/\(\(\d\|\a\|*\).*\n\)\@<!\(^\(\s\{8,}\|\t\+\)\).*\n/ end=/.\(\n^\s*\n\)\@=/ contained
230+
"}}}
231+
" Links: {{{2
232+
"
233+
" Base: {{{3
234+
syn region pandocReferenceLabel matchgroup=Operator start=/!\{,1}\\\@<!\[/ skip=/\(\\\@<!\]\]\@=\|`.*\\\@<!].*`\)/ end=/\\\@<!\]/ keepend display
235+
if g:pandoc#syntax#conceal#urls == 1
236+
syn region pandocReferenceURL matchgroup=Operator start=/\]\@1<=(/ end=/)/ keepend display conceal
237+
else
238+
syn region pandocReferenceURL matchgroup=Operator start=/\]\@1<=(/ end=/)/ keepend display
239+
endif
240+
" let's not consider "a [label] a" as a label, remove formatting - Note: breaks implicit links
241+
syn match pandocNoLabel /\]\@1<!\(\s\{,3}\|^\)\[[^\[\]]\{-}\]\(\s\+\|$\)[\[(]\@!/ contains=pandocPCite
242+
syn match pandocLinkTip /\s*".\{-}"/ contained containedin=pandocReferenceURL contains=@Spell display
243+
call s:WithConceal("image", 'syn match pandocImageIcon /!\[\@=/ display', 'conceal cchar='. s:cchars["image"])
244+
" }}}
245+
" Definitions: {{{3
246+
syn region pandocReferenceDefinition start=/\[.\{-}\]:/ end=/\(\n\s*".*"$\|$\)/ keepend
247+
syn match pandocReferenceDefinitionLabel /\[\zs.\{-}\ze\]:/ contained containedin=pandocReferenceDefinition display
248+
syn match pandocReferenceDefinitionAddress /:\s*\zs.*/ contained containedin=pandocReferenceDefinition
249+
syn match pandocReferenceDefinitionTip /\s*".\{-}"/ contained containedin=pandocReferenceDefinition,pandocReferenceDefinitionAddress contains=@Spell
250+
"}}}
251+
" Automatic_links: {{{3
252+
syn match pandocAutomaticLink /<\(https\{0,1}.\{-}\|.\{-}@.\{-}\..\{-}\)>/ contains=NONE
253+
" }}}
254+
"}}}
255+
" Citations: {{{2
256+
" parenthetical citations
257+
syn match pandocPCite /\[.\{-}-\{0,1}@.\{-}\]/ contains=pandocEmphasis,pandocStrong,pandocLatex,pandocCiteKey,@Spell display
258+
" in-text citations with location
259+
syn match pandocICite /@[[:graph:]äëïöüáéíóúàèìòùłßÄËÏÖÜÁÉÍÓÚÀÈÌÒÙŁß]*\s\[.\{-}\]/ contains=pandocCiteKey,@Spell display
260+
" cite keys
261+
syn match pandocCiteKey /\(-\=@[[:graph:]äëïöüáéíóúàèìòùłßÄËÏÖÜÁÉÍÓÚÀÈÌÒÙŁß]*\)\(\]\|\>\)\@=/ containedin=pandocPCite,pandocICite contains=@NoSpell display
262+
syn match pandocCiteAnchor /[-@]/ contained containedin=pandocCiteKey display
263+
syn match pandocCiteLocator /[\[\]]/ contained containedin=pandocPCite,pandocICite
264+
" }}}
265+
" Text Styles: {{{2
266+
267+
" Emphasis: {{{3
268+
"
269+
call s:WithConceal("block", 'syn region pandocEmphasis matchgroup=Operator start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\*\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell,pandocNoFormattedInEmphasis,pandocLatexInlineMath', 'concealends')
270+
call s:WithConceal("block", 'syn region pandocEmphasis matchgroup=Operator start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@1<=_\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell,pandocNoFormattedInEmphasis,pandocLatexInlineMath', 'concealends')
271+
" }}}
272+
" Strong: {{{3
273+
"
274+
call s:WithConceal("block", 'syn region pandocStrong matchgroup=Operator start=/\(\\\@<!\*\)\{2}/ end=/\(\\\@<!\*\)\{2}/ contains=@Spell,pandocNoFormattedInStrong,pandocLatexInlineMath', 'concealends')
275+
call s:WithConceal("block", 'syn region pandocStrong matchgroup=Operator start=/__/ end=/__/ contains=@Spell,pandocNoFormattedInStrong,pandocLatexInlineMath', 'concealends')
276+
"}}}
277+
" Strong Emphasis: {{{3
278+
"
279+
call s:WithConceal("block", 'syn region pandocStrongEmphasis matchgroup=Operator start=/\*\{3}\(\S[^*]*\(\*\S\|\n[^*]*\*\S\)\)\@=/ end=/\S\@<=\*\{3}/ contains=@Spell', 'concealends')
280+
call s:WithConceal("block", 'syn region pandocStrongEmphasis matchgroup=Operator start=/\(___\)\S\@=/ end=/\S\@<=___/ contains=@Spell', 'concealends')
281+
" }}}
282+
" Mixed: {{{3
283+
call s:WithConceal("block", 'syn region pandocStrongInEmphasis matchgroup=Operator start=/\*\*/ end=/\*\*/ contained containedin=pandocEmphasis contains=@Spell', 'concealends')
284+
call s:WithConceal("block", 'syn region pandocStrongInEmphasis matchgroup=Operator start=/__/ end=/__/ contained containedin=pandocEmphasis contains=@Spell', 'concealends')
285+
call s:WithConceal("block", 'syn region pandocEmphasisInStrong matchgroup=Operator start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=\*\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=pandocStrong contains=@Spell', 'concealends')
286+
call s:WithConceal("block", 'syn region pandocEmphasisInStrong matchgroup=Operator start=/\\\@<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=_\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=pandocStrong contains=@Spell', 'concealends')
287+
288+
" Inline Code: {{{3
289+
290+
" Using single back ticks
291+
call s:WithConceal("inlinecode", 'syn region pandocNoFormatted matchgroup=Operator start=/\\\@<!`/ end=/\\\@<!`/ nextgroup=pandocNoFormattedAttrs', 'concealends')
292+
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInEmphasis matchgroup=Operator start=/\\\@<!`/ end=/\\\@<!`/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
293+
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInStrong matchgroup=Operator start=/\\\@<!`/ end=/\\\@<!`/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
294+
" Using double back ticks
295+
call s:WithConceal("inlinecode", 'syn region pandocNoFormatted matchgroup=Operator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs', 'concealends')
296+
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInEmphasis matchgroup=Operator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
297+
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInStrong matchgroup=Operator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
298+
syn match pandocNoFormattedAttrs /{.\{-}}/ contained
299+
"}}}
300+
" Subscripts: {{{3
301+
syn region pandocSubscript start=/\~\(\([[:graph:]]\(\\ \)\=\)\{-}\~\)\@=/ end=/\~/ keepend
302+
call s:WithConceal("subscript", 'syn match pandocSubscriptMark /\~/ contained containedin=pandocSubscript', 'conceal cchar='.s:cchars["sub"])
303+
"}}}
304+
" Superscript: {{{3
305+
syn region pandocSuperscript start=/\^\(\([[:graph:]]\(\\ \)\=\)\{-}\^\)\@=/ skip=/\\ / end=/\^/ keepend
306+
call s:WithConceal("superscript", 'syn match pandocSuperscriptMark /\^/ contained containedin=pandocSuperscript', 'conceal cchar='.s:cchars["super"])
307+
"}}}
308+
" Strikeout: {{{3
309+
syn region pandocStrikeout start=/\~\~/ end=/\~\~/ contains=@Spell keepend
310+
call s:WithConceal("strikeout", 'syn match pandocStrikeoutMark /\~\~/ contained containedin=pandocStrikeout', 'conceal cchar='.s:cchars["strike"])
311+
" }}}
312+
" }}}
313+
" Headers: {{{2
314+
"
315+
syn match pandocAtxHeader /\(\%^\|<.\+>.*\n\|^\s*\n\)\@<=#\{1,6}.*\n/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,@Spell, display
316+
syn match pandocAtxHeaderMark /\(^#\{1,6}\|\\\@<!#\+\(\s*.*$\)\@=\)/ contained containedin=pandocAtxHeader
317+
call s:WithConceal("atx", 'syn match pandocAtxStart /#/ contained containedin=pandocAtxHeaderMark', 'conceal cchar='.s:cchars["atx"])
318+
syn match pandocSetexHeader /^.\+\n[=]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,@Spell
319+
syn match pandocSetexHeader /^.\+\n[-]\+$/ contains=pandocEmphasis,pandocStrong,pandocNoFormatted,pandocLaTeXInlineMath,@Spell
320+
syn match pandocHeaderAttr /{.*}/ contained containedin=pandocAtxHeader,pandocSetexHeader
321+
syn match pandocHeaderID /#[-_:.[:alpha:]]*/ contained containedin=pandocHeaderAttr
322+
"}}}
323+
" Line Blocks: {{{2
324+
syn region pandocLineBlock start=/^|/ end=/\(^|\(.*\n|\@!\)\@=.*\)\@<=\n/ transparent
325+
syn match pandocLineBlockDelimiter /^|/ contained containedin=pandocLineBlock
326+
"}}}
327+
" Tables: {{{2
328+
329+
" Simple: {{{3
330+
331+
syn region pandocSimpleTable start=/\%#=2\(^.*[[:graph:]].*\n\)\@<!\(^.*[[:graph:]].*\n\)\(-\+\s*\)\+\n\n\@!/ end=/\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
332+
syn match pandocSimpleTableDelims /\-/ contained containedin=pandocSimpleTable
333+
syn match pandocSimpleTableHeader /\%#=2\(^.*[[:graph:]].*\n\)\@<!\(^.*[[:graph:]].*\n\)/ contained containedin=pandocSimpleTable
334+
335+
syn region pandocTable start=/\%#=2^\(-\+\s*\)\+\n\n\@!/ end=/\%#=2^\(-\+\s*\)\+\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
336+
syn match pandocTableDelims /\-/ contained containedin=pandocTable
337+
syn region pandocTableMultilineHeader start=/\%#=2\(^-\+\n\)\@<=./ end=/\%#=2\n-\@=/ contained containedin=pandocTable
338+
339+
" }}}3
340+
" Grid: {{{3
341+
syn region pandocGridTable start=/\%#=2\n\@1<=+-/ end=/+\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
342+
syn match pandocGridTableDelims /[\|=]/ contained containedin=pandocGridTable
343+
syn match pandocGridTableDelims /\%#=2\([\-+][\-+=]\@=\|[\-+=]\@1<=[\-+]\)/ contained containedin=pandocGridTable
344+
syn match pandocGridTableHeader /\%#=2\(^.*\n\)\(+=.*\)\@=/ contained containedin=pandocGridTable
345+
"}}}3
346+
" Pipe: {{{3
347+
" with beginning and end pipes
348+
syn region pandocPipeTable start=/\%#=2\([+|]\n\)\@<!\n\@1<=|\(.*|\)\@=/ end=/|.*\n\(\n\|{\)/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
349+
" without beginning and end pipes
350+
syn region pandocPipeTable start=/\%#=2^.*\n-.\{-}|/ end=/|.*\n\n/ keepend
351+
syn match pandocPipeTableDelims /[\|\-:+]/ contained containedin=pandocPipeTable
352+
syn match pandocPipeTableHeader /\(^.*\n\)\(|-\)\@=/ contained containedin=pandocPipeTable
353+
syn match pandocPipeTableHeader /\(^.*\n\)\(-\)\@=/ contained containedin=pandocPipeTable
354+
" }}}3
355+
syn match pandocTableHeaderWord /\<.\{-}\>/ contained containedin=pandocGridTableHeader,pandocPipeTableHeader
356+
" }}}2
357+
" Delimited Code Blocks: {{{2
358+
" this is here because we can override strikeouts and subscripts
359+
syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\(\s\{4,}\)\=\~\{3,}\~*\)/ end=/^\z1\~*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend
360+
syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\(\s\{4,}\)\=`\{3,}`*\)/ end=/^\z1`*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend
361+
call s:WithConceal("codeblock_start", 'syn match pandocDelimitedCodeBlockStart /\(\_^\n\_^\(>\s\)\?\(\s\{4,}\)\=\)\@<=\(\~\{3,}\~*\|`\{3,}`*\)/ contained containedin=pandocDelimitedCodeBlock nextgroup=pandocDelimitedCodeBlockLanguage', 'conceal cchar='.s:cchars["codelang"])
362+
syn match pandocDelimitedCodeBlockLanguage /\(\s\?\)\@<=.\+\(\_$\)\@=/ contained
363+
call s:WithConceal("codeblock_delim", 'syn match pandocDelimitedCodeBlockEnd /\(`\{3,}`*\|\~\{3,}\~*\)\(\_$\n\(>\s\)\?\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock', 'conceal cchar='.s:cchars["codeend"])
364+
syn match pandocBlockQuoteinDelimitedCodeBlock '^>' contained containedin=pandocDelimitedCodeBlock
365+
syn match pandocCodePre /<pre>.\{-}<\/pre>/ skipnl
366+
syn match pandocCodePre /<code>.\{-}<\/code>/ skipnl
367+
368+
" enable highlighting for embedded region in codeblocks if there exists a
369+
" g:pandoc#syntax#codeblocks#embeds#langs *list*.
370+
"
371+
" entries in this list are the language code interpreted by pandoc,
372+
" if this differs from the name of the vim syntax file, append =vimname
373+
" e.g. let g:pandoc#syntax#codeblocks#embeds#langs = ["haskell", "literatehaskell=lhaskell"]
374+
"
375+
if g:pandoc#syntax#codeblocks#embeds#use != 0
376+
for l in g:pandoc#syntax#codeblocks#embeds#langs
377+
call EnableEmbedsforCodeblocksWithLang(l)
378+
endfor
379+
endif
380+
" }}}
381+
" Abbreviations: {{{2
382+
syn region pandocAbbreviationDefinition start=/^\*\[.\{-}\]:\s*/ end="$" contains=pandocNoFormatted,@Spell
383+
call s:WithConceal('abbrev', 'syn match pandocAbbreviationSeparator /:/ contained containedin=pandocAbbreviationDefinition', "conceal cchar=".s:cchars["abbrev"])
384+
syn match pandocAbbreviation /\*\[.\{-}\]/ contained containedin=pandocAbbreviationDefinition
385+
call s:WithConceal('abbrev', 'syn match pandocAbbreviationHead /\*\[/ contained containedin=pandocAbbreviation', "conceal")
386+
call s:WithConceal('abbrev', 'syn match pandocAbbreviationTail /\]/ contained containedin=pandocAbbreviation', "conceal")
387+
" }}}
388+
" Footnotes: {{{2
389+
" we put these here not to interfere with superscripts.
390+
"
391+
syn match pandocFootnoteID /\[\^[^\]]\+\]/ nextgroup=pandocFootnoteDef
392+
" Inline footnotes
393+
syn region pandocFootnoteDef start=/\^\[/ end=/\]/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,,pandocEnDash,pandocEmDash,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell skipnl keepend
394+
call s:WithConceal("footnote", 'syn match pandocFootnoteDefHead /\^\[/ contained containedin=pandocFootnoteDef', 'conceal cchar='.s:cchars["footnote"])
395+
call s:WithConceal("footnote", 'syn match pandocFootnoteDefTail /\]/ contained containedin=pandocFootnoteDef', 'conceal')
396+
397+
" regular footnotes
398+
syn region pandocFootnoteBlock start=/\[\^.\{-}\]:\s*\n*/ end=/^\n^\s\@!/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocNewLine,pandocStrongEmphasis,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell skipnl
399+
syn match pandocFootnoteBlockSeparator /:/ contained containedin=pandocFootnoteBlock
400+
syn match pandocFootnoteID /\[\^.\{-}\]/ contained containedin=pandocFootnoteBlock
401+
call s:WithConceal("footnote", 'syn match pandocFootnoteIDHead /\[\^/ contained containedin=pandocFootnoteID', 'conceal cchar='.s:cchars["footnote"])
402+
call s:WithConceal("footnote", 'syn match pandocFootnoteIDTail /\]/ contained containedin=pandocFootnoteID', 'conceal')
403+
" }}}
404+
" List Items: {{{2
405+
"
406+
" Unordered lists
407+
syn match pandocUListItem /^>\=\s*[*+-]\s\+-\@!.*$/ nextgroup=pandocUListItem,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocReferenceURL,pandocAutomaticLink skipempty display
408+
call s:WithConceal('list', 'syn match pandocUListItemBullet /^>\=\s*\zs[*+-]/ contained containedin=pandocUListItem', 'conceal cchar='.s:cchars['li'])
409+
410+
" Ordered lists
411+
syn match pandocListItem /^\s*(\?\(\d\+\|\l\|\#\|@\)[.)].*$/ nextgroup=pandocListItem,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink skipempty display
412+
" support for roman numerals up to 'c'
413+
if g:pandoc#syntax#roman_lists != 0
414+
syn match pandocListItem /^\s*(\?x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}[.)].*$/ nextgroup=pandocListItem,pandocMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation,pandocAutomaticLink skipempty display
415+
endif
416+
syn match pandocListItemBullet /^(\?.\{-}[.)]/ contained containedin=pandocListItem
417+
syn match pandocListItemBulletId /\(\d\+\|\l\|\#\|@.\{-}\|x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}\)/ contained containedin=pandocListItemBullet
418+
419+
syn match pandocListItemContinuation /^\s\+\([-+*]\s\+\|(\?.\+[).]\)\@<!\([[:alpha:]ñäëïöüáéíóúàèìòùłßÄËÏÖÜÁÉÍÓÚÀÈÌÒÙŁß_"[]\|\*\S\)\@=.*$/ nextgroup=pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation,pandocListItem contains=@Spell,pandocEmphasis,pandocStrong,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocStrongEmphasis,pandocStrongEmphasis,pandocPCite,pandocICite,pandocCiteKey,pandocReferenceLabel,pandocReferenceURL,pandocLaTeXCommand,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink contained skipempty display
420+
" }}}
421+
" Definitions: {{{2
422+
"
423+
syn region pandocDefinitionBlock start=/^\%(\_^\s*\([`~]\)\1\{2,}\)\@!.*\n\(^\s*\n\)\=\s\{0,2}[:~]\(\~\{2,}\~*\)\@!/ skip=/\n\n\zs\s/ end=/\n\n/ contains=pandocDefinitionBlockMark,pandocDefinitionBlockTerm,pandocCodeBlockInsideIndent,pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocFootnoteID,pandocReferenceURL,pandocReferenceLabel,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocAutomaticLink,pandocEmDash,pandocEnDash
424+
syn match pandocDefinitionBlockTerm /^.*\n\(^\s*\n\)\=\(\s*[:~]\)\@=/ contained contains=pandocNoFormatted,pandocEmphasis,pandocStrong,pandocLaTeXInlineMath nextgroup=pandocDefinitionBlockMark
425+
call s:WithConceal("definition", 'syn match pandocDefinitionBlockMark /^\s*[:~]/ contained', 'conceal cchar='.s:cchars["definition"])
426+
" }}}
427+
" Special: {{{2
428+
429+
" New_lines: {{{3
430+
if g:pandoc#syntax#newlines == 1
431+
call s:WithConceal("newline", 'syn match pandocNewLine /\( \|\\\)$/ display containedin=pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocStrongInEmphasis,pandocEmphasisInStrong', 'conceal cchar='.s:cchars["newline"])
432+
endif
433+
"}}}
434+
" Emdashes: {{{3
435+
if &encoding == "utf-8"
436+
call s:WithConceal("emdashes", 'syn match pandocEllipses /\([^-]\)\@<=---\([^-]\)\@=/ display', 'conceal cchar=—')
437+
endif
438+
" }}}
439+
" Endashes: {{{3
440+
if &encoding == "utf-8"
441+
call s:WithConceal("endashes", 'syn match pandocEllipses /\([^-]\)\@<=--\([^-]\)\@=/ display', 'conceal cchar=–')
442+
endif
443+
" }}}
444+
" Ellipses: {{{3
445+
if &encoding == "utf-8"
446+
call s:WithConceal("ellipses", 'syn match pandocEllipses /\.\.\./ display', 'conceal cchar=…')
447+
endif
448+
" }}}
449+
" Quotes: {{{3
450+
if &encoding == "utf-8"
451+
call s:WithConceal("quotes", 'syn match pandocBeginQuote /"\</ containedin=pandocEmphasis,pandocStrong,pandocListItem,pandocListItemContinuation,pandocUListItem display', 'conceal cchar=“')
452+
call s:WithConceal("quotes", 'syn match pandocEndQuote /\(\>[[:punct:]]*\)\@<="[[:blank:][:punct:]\n]\@=/ containedin=pandocEmphasis,pandocStrong,pandocUListItem,pandocListItem,pandocListItemContinuation display', 'conceal cchar=”')
453+
endif
454+
" Hrule: {{{3
455+
syn match pandocHRule /^\s*\([*\-_]\)\s*\%(\1\s*\)\{2,}$/ display
456+
" Backslashes: {{{3
457+
if g:pandoc#syntax#conceal#backslash == 1
458+
syn match pandocBackslash /\\\@<!\\/ containedin=ALLBUT,pandocCodeblock,pandocCodeBlockInsideIndent,pandocNoFormatted,pandocNoFormattedInEmphasis,pandocNoFormattedInStrong,pandocDelimitedCodeBlock,pandocLineBlock,pandocYAMLHeader conceal
459+
endif
460+
" }}}
461+
" }}}
462+
" YAML: {{{2
463+
464+
try
465+
unlet! b:current_syntax
466+
syn include @YAML syntax/yaml.vim
467+
catch /E484/
468+
endtry
469+
syn region pandocYAMLHeader start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=@YAML containedin=TOP
470+
"}}}
471+
"}}}1
472+
473+
" Styling: {{{1
474+
" override this for consistency
475+
hi pandocTitleBlock term=italic gui=italic
476+
hi link pandocTitleBlockTitle Directory
477+
hi link pandocAtxHeader Title
478+
hi link pandocAtxStart Operator
479+
hi link pandocSetexHeader Title
480+
hi link pandocHeaderAttr Comment
481+
hi link pandocHeaderID Identifier
482+
483+
hi link pandocLaTexSectionCmd texSection
484+
hi link pandocLaTeXDelimiter texDelimiter
485+
486+
hi link pandocHTMLComment Comment
487+
hi link pandocHTMLCommentStart Delimiter
488+
hi link pandocHTMLCommentEnd Delimiter
489+
hi link pandocBlockQuote Comment
490+
hi link pandocBlockQuoteMark Comment
491+
492+
" if the user sets g:pandoc#syntax#codeblocks#ignore to contain
493+
" a codeblock type, don't highlight it so that it remains Normal
494+
495+
if index(g:pandoc#syntax#codeblocks#ignore, 'definition') == -1
496+
hi link pandocCodeBlockInsideIndent String
497+
endif
498+
499+
if index(g:pandoc#syntax#codeblocks#ignore, 'delimited') == -1
500+
hi link pandocDelimitedCodeBlock Special
501+
endif
502+
503+
hi link pandocDelimitedCodeBlockStart Delimiter
504+
hi link pandocDelimitedCodeBlockEnd Delimiter
505+
hi link pandocDelimitedCodeBlockLanguage Comment
506+
hi link pandocBlockQuoteinDelimitedCodeBlock pandocBlockQuote
507+
hi link pandocCodePre String
508+
509+
hi link pandocLineBlockDelimiter Delimiter
510+
511+
hi link pandocListItemBullet Operator
512+
hi link pandocUListItemBullet Operator
513+
hi link pandocListItemBulletId Identifier
514+
515+
hi link pandocReferenceLabel Label
516+
hi link pandocReferenceURL Underlined
517+
hi link pandocLinkTip Identifier
518+
hi link pandocImageIcon Operator
519+
520+
hi link pandocReferenceDefinition Operator
521+
hi link pandocReferenceDefinitionLabel Label
522+
hi link pandocReferenceDefinitionAddress Underlined
523+
hi link pandocReferenceDefinitionTip Identifier
524+
525+
hi link pandocAutomaticLink Underlined
526+
527+
hi link pandocDefinitionBlockTerm Identifier
528+
hi link pandocDefinitionBlockMark Operator
529+
530+
hi link pandocSimpleTableDelims Delimiter
531+
hi link pandocSimpleTableHeader pandocStrong
532+
hi link pandocTableMultilineHeader pandocStrong
533+
hi link pandocTableDelims Delimiter
534+
hi link pandocGridTableDelims Delimiter
535+
hi link pandocGridTableHeader Delimiter
536+
hi link pandocPipeTableDelims Delimiter
537+
hi link pandocPipeTableHeader Delimiter
538+
hi link pandocTableHeaderWord pandocStrong
539+
540+
hi link pandocAbbreviationHead Type
541+
hi link pandocAbbreviation Label
542+
hi link pandocAbbreviationTail Type
543+
hi link pandocAbbreviationSeparator Identifier
544+
hi link pandocAbbreviationDefinition Comment
545+
546+
hi link pandocFootnoteID Label
547+
hi link pandocFootnoteIDHead Type
548+
hi link pandocFootnoteIDTail Type
549+
hi link pandocFootnoteDef Comment
550+
hi link pandocFootnoteDefHead Type
551+
hi link pandocFootnoteDefTail Type
552+
hi link pandocFootnoteBlock Comment
553+
hi link pandocFootnoteBlockSeparator Operator
554+
555+
hi link pandocPCite Normal
556+
hi link pandocICite Normal
557+
hi link pandocCiteKey Identifier
558+
hi link pandocCiteAnchor Operator
559+
hi link pandocCiteLocator Operator
560+
561+
if g:pandoc#syntax#style#emphases == 1
562+
hi pandocEmphasis gui=italic cterm=italic
563+
hi pandocStrong gui=bold cterm=bold
564+
hi pandocStrongEmphasis gui=bold,italic cterm=bold,italic
565+
hi pandocStrongInEmphasis gui=bold,italic cterm=bold,italic
566+
hi pandocEmphasisInStrong gui=bold,italic cterm=bold,italic
567+
if !exists('s:hi_tail')
568+
for s:i in ["fg", "bg"]
569+
let s:tmp_val = synIDattr(synIDtrans(hlID("String")), s:i)
570+
let s:tmp_ui = has('gui_running') || has('nvim') ? 'gui' : 'cterm'
571+
if !empty(s:tmp_val) && s:tmp_val != -1
572+
exe 'let s:'.s:i . ' = "'.s:tmp_ui.s:i.'='.s:tmp_val.'"'
573+
else
574+
exe 'let s:'.s:i . ' = ""'
575+
endif
576+
endfor
577+
let s:hi_tail = ' '.s:fg.' '.s:bg
578+
endif
579+
exe 'hi pandocNoFormattedInEmphasis gui=italic cterm=italic'.s:hi_tail
580+
exe 'hi pandocNoFormattedInStrong gui=bold cterm=bold'.s:hi_tail
581+
endif
582+
hi link pandocNoFormatted String
583+
hi link pandocNoFormattedAttrs Comment
584+
hi link pandocSubscriptMark Operator
585+
hi link pandocSuperscriptMark Operator
586+
hi link pandocStrikeoutMark Operator
587+
if g:pandoc#syntax#style#underline_special == 1
588+
hi pandocSubscript gui=underline cterm=underline
589+
hi pandocSuperscript gui=underline cterm=underline
590+
hi pandocStrikeout gui=underline cterm=underline
591+
endif
592+
hi link pandocNewLine Error
593+
hi link pandocHRule Delimiter
594+
595+
"}}}
596+
597+
syntax sync clear
598+
syntax sync minlines=100

0 commit comments

Comments
 (0)
Please sign in to comment.