Skip to content

Commit 0e1f9af

Browse files
committed
correct highlights of hrules and YAML headers
Highlight horizontal rules according to http://johnmacfarlane.net/pandoc/README.html#horizontal-rules (i.e. 3 possible symbols optionally delimited or surrounded by spaces). Correctly distinguish hrules and YAML headers: the latter must begin from line with exactly 3 dashes with non-blank line. This is not clearly stated in pandoc docs but is as implemented in pandoc: see source code of function yamlMetaBlock from http://hackage.haskell.org/package/pandoc-1.13.2/docs/src/Text-Pandoc-Readers-Markdown.html, here is an excerpt: yamlMetaBlock = try $ do guardEnabled Ext_yaml_metadata_block pos <- getPosition string "---" blankline notFollowedBy blankline -- if --- is followed by a blank it's an HRULE This commit must also fix #119
1 parent 1801845 commit 0e1f9af

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

syntax/pandoc.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ if &encoding == "utf-8"
445445
call s:WithConceal("quotes", 'syn match pandocEndQuote /\(\>[[:punct:]]*\)\@<="[[:blank:][:punct:]\n]\@=/ containedin=pandocEmphasis,pandocStrong,pandocUListItem,pandocListItem,pandocListItemContinuation display', 'conceal cchar=”')
446446
endif
447447
" Hrule: {{{3
448-
syn match pandocHRule /\*\{3}$/ display
448+
syn match pandocHRule /^\s*\([*-_]\)\s*\%(\1\s*\)\{2,}$/ display
449449
" Backslashes: {{{3
450450
if g:pandoc#syntax#conceal#backslash == 1
451451
syn match pandocBackslash /\\\@<!\\/ containedin=ALLBUT,pandocCodeblock,pandocCodeBlockInsideIndent,pandocNoFormatted,pandocNoFormattedInEmphasis,pandocNoFormattedInStrong,pandocDelimitedCodeBlock,pandocLineBlock conceal
@@ -459,7 +459,7 @@ try
459459
syn include @YAML colors/yaml.vim
460460
catch /E484/
461461
endtry
462-
syn region pandocYAMLHeader matchgroup=Delimiter start=/\(\%^\|\(\s*.*\n\)\)\@<=\-\{3}\s*$/ end=/[\-|\.]\{3}\s*$/ contains=@YAML containedin=TOP
462+
syn region pandocYAMLHeader matchgroup=Delimiter start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ contains=@YAML containedin=TOP
463463
"}}}
464464
"}}}1
465465

0 commit comments

Comments
 (0)