|
1 | 1 | " Vim syntax file
|
2 | 2 | " Filetype: pandoc
|
3 |
| -" Language: CommonMark |
4 |
| -" Maintainer: Caleb Maclennan <[email protected]> |
| 3 | +" Language: pandoc markdown, simplified |
5 | 4 | " Maintainer: Felipe Morales <[email protected]>
|
6 | 5 |
|
7 | 6 | scriptencoding utf-8
|
8 | 7 |
|
9 |
| -if exists('b:current_syntax') |
10 |
| - finish |
11 |
| -endif |
| 8 | +syntax clear |
12 | 9 |
|
13 |
| -if !exists('b:is_legacy') |
14 |
| - let b:is_legacy = exists('g:pandoc_legacy') |
15 |
| -endif |
| 10 | +syn spell toplevel |
16 | 11 |
|
17 |
| -if b:is_legacy |
18 |
| - syntax clear |
19 |
| -else |
20 |
| - source pandoc_legacy.vim |
21 |
| -endif |
| 12 | +" A pandoc markdown document is based on blocks. |
22 | 13 |
|
23 |
| -let b:current_syntax = b:is_legacy ? 'pandoc' : 'pandoc_legacy' |
| 14 | +syn region pdcPar start=/^\s*[[:print:]]/ end=/[[:print:]]\(\n\s*\n\)\@=/ keepend contains=@Spell |
| 15 | + |
| 16 | +" YAML headers |
| 17 | +unlet! b:current_syntax |
| 18 | +syn include @YAML syntax/yaml.vim |
| 19 | +syn region pdcYAML matchgroup=Delimiter start=/^\s*---\(\n\s*[[:print:]]\)\@=/ end=/---\n\s*\n/ keepend contains=@YAML |
| 20 | + |
| 21 | +" LaTeX environments |
| 22 | +unlet! b:current_syntax |
| 23 | +syn include @LATEX syntax/tex.vim |
| 24 | +syn region pdcLaTeXEnv start=/\\begin{\z(.\{-}\)}/ end=/\\end{\z1}/ keepend contains=@LATEX |
| 25 | +syn region pdcLaTeXDisplayMath start=/\z(\\\@<!\$\{1,2}\)/ end=/\z1/ keepend contains=@LATEX containedin=pdcPar,pdcBlockQuote,pdcOList,pdcUList,pdcFootnote,pdcFootnotePar |
| 26 | +"syn match pdcLaTeXCmd /\\\S\{1,}/ contains=@LATEX keepend containedin=pdcPar |
| 27 | +syn match pdcLaTeXCmd /\\[[:alpha:]]\+\(\({.\{-}}\)\=\(\[.\{-}\]\)\=\)*/ contains=@LATEX keepend containedin=pdcPar,pdcBlockQuote,pdcOList,pdcUList,pdcFootnote,pdcFootnotePar |
| 28 | + |
| 29 | +" Code Blocks |
| 30 | +syn region pdcCodeblock start=/^\(\s\{4,}\|\t\{1,}\)/ end=/[[:print:]]\zs\n\ze\s*\n/ |
| 31 | +syn region pdcDelimitedCodeBlock start=/^\z([`~]\{3}\)/ end=/\z1\n\s*\n/ |
| 32 | +syn region pdcLaTeXCodeBlock matchgroup=Delimiter start=/^```{=latex}/ end=/```\n\s*\n/ keepend contains=@LATEX |
| 33 | + |
| 34 | +" Blockquotes |
| 35 | +syn region pdcBlockQuote start=/^\s\{,3}>\s\?/ end=/[[:print:]]\(\n\s*\n\)\@=/ keepend |
| 36 | + |
| 37 | +" Lists |
| 38 | +syn region pdcUList start=/^>\=\s*[*=-]\ze\s*[[:print:]]$/ end=/[[:print:]]\(\n\s*\n\)\@=/ keepend |
| 39 | +syn region pdcOList start=/^(\?\(\d\+\|\l\|\#\|@.\{-}\|x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}\)[.)]/ end=/[[:print:]]\(\n\s*\n\)\@=/ keepend |
| 40 | + |
| 41 | +" Fenced DIVS |
| 42 | +syn region pdcFencedDiv matchgroup=Delimiter start=/^:::.*$/ end=/:::\n\s*\n/ keepend contains=@LATEX,pdcPar contains=@Spell |
| 43 | + |
| 44 | +" Atx headers |
| 45 | +syn match pdcAtxHeader /\(\%^\|<.\+>.*\n\|^\s*\n\)\@<=#\{1,6}.*\n/ keepend contained containedin=pdcPar contains=@Spell |
| 46 | + |
| 47 | +" Footnotes |
| 48 | +syn region pdcFootnote start=/^\[\^/ end=/[[:print:]]\zs\n\ze\s*\n/ keepend contains=@Spell |
| 49 | +syn region pdcInlineFootnote matchgroup=Delimiter start=/\^\[/ skip=/\[[[:print:]]*\]/ end=/\]/ keepend contained containedin=pdcPar,pdcUList,pdcOList |
| 50 | +syn region pdcFootnoteRef matchgroup=Delimiter start=/\[\^/ end=/\]/ contained containedin=pdcPar,pdcBlockQuote,pdcUList,pdcOList,pdcFootnote nextgroup=pdcFootnotePar |
| 51 | +syn region pdcFootnotePar start=/^\t[[:print:]]/ end=/[[:print:]]\(\n\s*\n\)\@=/ keepend contains=@Spell nextgroup=pdcFootnotePar |
| 52 | + |
| 53 | +" References. |
| 54 | +syn match pdcBibRef /@[[:alnum:]:_-]\{1,}\(\[[[:print:]]\{-}\]\)\?/ containedin=pdcPar,pdcUList,pdcOList,pdcBlockQuote |
| 55 | +syn match pdcBibRefIF /@[[:alnum:]:_-]\{1,}\(\[[[:print:]]\{-}\]\)\?/ containedin=pdcInlineFootnote,pdcFootnote,pdcFootnotePar |
| 56 | + |
| 57 | +let b:current_syntax = 'pandoc' |
| 58 | + |
| 59 | +hi def link pdcCodeblock Special |
| 60 | +hi def link pdcDelimitedCodeBlock pdcCodeblock |
| 61 | +hi def link pdcAtxHeader Directory |
| 62 | +hi def link pdcFootnote Comment |
| 63 | +hi def link pdcInlineFootnote pdcFootnote |
| 64 | +hi def link pdcFootnotePar pdcFootnote |
| 65 | +hi def link pdcFootnoteBlockQuote pdcFootnote |
| 66 | +hi def pdcBodyLink ctermfg=fg guifg=fg guisp=SteelBlue4 gui=underline cterm=underline |
| 67 | +let fn_fg = pandoc#syntax#color#Instrospect('pdcInlineFootnote').guifg |
| 68 | +exe 'hi def pdcFootLink guifg='.fn_fg.' guisp=SteelBlue4 gui=underline cterm=underline' |
| 69 | +hi def link pdcBibRef pdcBodyLink |
| 70 | +hi def link pdcFootnoteRef pdcFootLink |
| 71 | +hi def link pdcBibRefIF pdcFootLink |
0 commit comments