Skip to content

Commit 4970ba6

Browse files
committed
Strip trailing whitespace and normalize indentation, see #192
1 parent 1e91085 commit 4970ba6

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

syntax/pandoc.vim

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
scriptencoding utf-8
22
" vim: set fdm=marker foldlevel=0:
3-
"
3+
"
44
" Vim syntax file
55
"
66
" Language: Pandoc (superset of Markdown)
@@ -15,14 +15,14 @@ scriptencoding utf-8
1515
" use conceal? {{{2
1616
if !exists("g:pandoc#syntax#conceal#use")
1717
if v:version < 703
18-
let g:pandoc#syntax#conceal#use = 0
18+
let g:pandoc#syntax#conceal#use = 0
1919
else
20-
let g:pandoc#syntax#conceal#use = 1
20+
let g:pandoc#syntax#conceal#use = 1
2121
endif
2222
else
2323
" exists, but we cannot use it, disable anyway
2424
if v:version < 703
25-
let g:pandoc#syntax#conceal#use = 0
25+
let g:pandoc#syntax#conceal#use = 0
2626
endif
2727
endif
2828
"}}}2
@@ -34,36 +34,36 @@ endif
3434
" cchars used in conceal rules {{{2
3535
" utf-8 defaults (preferred)
3636
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": "",
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": "",
5050
\"html_c_s": "",
5151
\"html_c_e": ""}
5252
else
5353
" ascii defaults
54-
let s:cchars = {
55-
\"newline": " ",
56-
\"image": "i",
57-
\"super": "^",
58-
\"sub": "_",
59-
\"strike": "~",
60-
\"atx": "#",
61-
\"codelang": "l",
62-
\"codeend": "-",
63-
\"abbrev": "a",
64-
\"footnote": "f",
65-
\"definition": " ",
66-
\"li": "*",
54+
let s:cchars = {
55+
\"newline": " ",
56+
\"image": "i",
57+
\"super": "^",
58+
\"sub": "_",
59+
\"strike": "~",
60+
\"atx": "#",
61+
\"codelang": "l",
62+
\"codeend": "-",
63+
\"abbrev": "a",
64+
\"footnote": "f",
65+
\"definition": " ",
66+
\"li": "*",
6767
\"html_c_s": "+",
6868
\"html_c_e": "+"}
6969
endif
@@ -78,7 +78,7 @@ if !exists("g:pandoc#syntax#conceal#urls")
7878
let g:pandoc#syntax#conceal#urls = 0
7979
endif
8080
" should backslashes in escapes be concealed? {{{2
81-
if !exists("g:pandoc#syntax#conceal#backslash")
81+
if !exists("g:pandoc#syntax#conceal#backslash")
8282
let g:pandoc#syntax#conceal#backslash = 0
8383
endif
8484
"}}}2
@@ -148,12 +148,12 @@ function! EnableEmbedsforCodeblocksWithLang(entry)
148148
unlet! b:current_syntax
149149
exe 'syn include @'.toupper(s:langname).' syntax/'.s:langsyntaxfile.'.vim'
150150
exe "syn region pandocDelimitedCodeBlock_" . s:langname . ' start=/\(\_^\([ ]\{4,}\|\t\)\=\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>.*\n\)\@<=\_^/' .
151-
\' end=/\_$\n\(\([ ]\{4,}\|\t\)\=\(`\{3,}`*\|\~\{3,}\~*\)\_$\n\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock' .
152-
\' contains=@' . toupper(s:langname)
153-
exe "syn region pandocDelimitedCodeBlockinBlockQuote_" . s:langname . ' start=/>\s\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>/' .
154-
\ ' end=/\(`\{3,}`*\|\~\{3,}\~*\)/ contained containedin=pandocDelimitedCodeBlock' .
155-
\' contains=@' . toupper(s:langname) .
156-
\",pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd,pandodDelimitedCodeblockLang,pandocBlockQuoteinDelimitedCodeBlock"
151+
\' end=/\_$\n\(\([ ]\{4,}\|\t\)\=\(`\{3,}`*\|\~\{3,}\~*\)\_$\n\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock' .
152+
\' contains=@' . toupper(s:langname)
153+
exe "syn region pandocDelimitedCodeBlockinBlockQuote_" . s:langname . ' start=/>\s\(`\{3,}`*\|\~\{3,}\~*\)\s*\%({[^.]*\.\)\=' . s:langname . '\>/' .
154+
\ ' end=/\(`\{3,}`*\|\~\{3,}\~*\)/ contained containedin=pandocDelimitedCodeBlock' .
155+
\' contains=@' . toupper(s:langname) .
156+
\",pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd,pandodDelimitedCodeblockLang,pandocBlockQuoteinDelimitedCodeBlock"
157157
catch /E484/
158158
echo "No syntax file found for '" . s:langsyntaxfile . "'"
159159
endtry
@@ -173,9 +173,9 @@ endfunction
173173
function! s:WithConceal(rule_group, rule, conceal_rule)
174174
let l:rule_tail = ""
175175
if g:pandoc#syntax#conceal#use != 0
176-
if index(g:pandoc#syntax#conceal#blacklist, a:rule_group) == -1
177-
let l:rule_tail = " " . a:conceal_rule
178-
endif
176+
if index(g:pandoc#syntax#conceal#blacklist, a:rule_group) == -1
177+
let l:rule_tail = " " . a:conceal_rule
178+
endif
179179
endif
180180
execute a:rule . l:rule_tail
181181
endfunction
@@ -223,17 +223,17 @@ syn match pandocProtectedFromInlineLaTeX /\\\@<!\${.*}\(\(\s\|[[:punct:]]\)\([^$
223223
" contains=@LATEX
224224
syn region pandocLaTeXMathBlock start=/\$\$/ end=/\$\$/ keepend contains=@LATEX
225225
syn region pandocLaTeXMathBlock start=/\\\@<!\\\[/ end=/\\\@<!\\\]/ keepend contains=@LATEX
226-
syn match pandocLaTeXCommand /\\[[:alpha:]]\+\(\({.\{-}}\)\=\(\[.\{-}\]\)\=\)*/ contains=@LATEX
226+
syn match pandocLaTeXCommand /\\[[:alpha:]]\+\(\({.\{-}}\)\=\(\[.\{-}\]\)\=\)*/ contains=@LATEX
227227
syn region pandocLaTeXRegion start=/\\begin{\z(.\{-}\)}/ end=/\\end{\z1}/ keepend contains=@LATEX
228228
" we rehighlight sectioning commands, because otherwise tex.vim captures all text until EOF or a new sectioning command
229229
syn region pandocLaTexSection start=/\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)\*\=\(\[.*\]\)\={/ end=/\}/ keepend
230-
syn match pandocLaTexSectionCmd /\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)/ contained containedin=pandocLaTexSection
230+
syn match pandocLaTexSectionCmd /\\\(part\|chapter\|\(sub\)\{,2}section\|\(sub\)\=paragraph\)/ contained containedin=pandocLaTexSection
231231
syn match pandocLaTeXDelimiter /[[\]{}]/ contained containedin=pandocLaTexSection
232232
" }}}}
233233
" }}}2
234234
" Titleblock: {{{2
235235
"
236-
syn region pandocTitleBlock start=/\%^%/ end=/\n\n/ contains=pandocReferenceLabel,pandocReferenceURL,pandocNewLine
236+
syn region pandocTitleBlock start=/\%^%/ end=/\n\n/ contains=pandocReferenceLabel,pandocReferenceURL,pandocNewLine
237237
call s:WithConceal("titleblock", 'syn match pandocTitleBlockMark /%\ / contained containedin=pandocTitleBlock,pandocTitleBlockTitle', 'conceal')
238238
syn match pandocTitleBlockTitle /\%^%.*\n/ contained containedin=pandocTitleBlock
239239
"}}}
@@ -261,7 +261,7 @@ endif
261261
" let's not consider "a [label] a" as a label, remove formatting - Note: breaks implicit links
262262
syn match pandocNoLabel /\]\@1<!\(\s\{,3}\|^\)\[[^\[\]]\{-}\]\(\s\+\|$\)[\[(]\@!/ contains=pandocPCite
263263
syn match pandocLinkTip /\s*".\{-}"/ contained containedin=pandocReferenceURL contains=@Spell,pandocAmpersandEscape display
264-
call s:WithConceal("image", 'syn match pandocImageIcon /!\[\@=/ display', 'conceal cchar='. s:cchars["image"])
264+
call s:WithConceal("image", 'syn match pandocImageIcon /!\[\@=/ display', 'conceal cchar='. s:cchars["image"])
265265
" }}}
266266
" Definitions: {{{3
267267
syn region pandocReferenceDefinition start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" keepend
@@ -318,7 +318,7 @@ call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInEmphasis matchgr
318318
call s:WithConceal("inlinecode", 'syn region pandocNoFormattedInStrong matchgroup=pandocOperator start=/\\\@<!``/ end=/\\\@<!``/ nextgroup=pandocNoFormattedAttrs contained', 'concealends')
319319
syn match pandocNoFormattedAttrs /{.\{-}}/ contained
320320
"}}}
321-
" Subscripts: {{{3
321+
" Subscripts: {{{3
322322
syn region pandocSubscript start=/\~\(\([[:graph:]]\(\\ \)\=\)\{-}\~\)\@=/ end=/\~/ keepend
323323
call s:WithConceal("subscript", 'syn match pandocSubscriptMark /\~/ contained containedin=pandocSubscript', 'conceal cchar='.s:cchars["sub"])
324324
"}}}
@@ -362,11 +362,11 @@ syn region pandocTableMultilineHeader start=/\%#=2\(^-\{2,}\n\)\@<=./ end=/\%#=2
362362
syn region pandocGridTable start=/\%#=2\n\@1<=+-/ end=/+\n\n/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
363363
syn match pandocGridTableDelims /[\|=]/ contained containedin=pandocGridTable
364364
syn match pandocGridTableDelims /\%#=2\([\-+][\-+=]\@=\|[\-+=]\@1<=[\-+]\)/ contained containedin=pandocGridTable
365-
syn match pandocGridTableHeader /\%#=2\(^.*\n\)\(+=.*\)\@=/ contained containedin=pandocGridTable
365+
syn match pandocGridTableHeader /\%#=2\(^.*\n\)\(+=.*\)\@=/ contained containedin=pandocGridTable
366366
"}}}3
367367
" Pipe: {{{3
368368
" with beginning and end pipes
369-
syn region pandocPipeTable start=/\%#=2\([+|]\n\)\@<!\n\@1<=|\(.*|\)\@=/ end=/|.*\n\(\n\|{\)/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
369+
syn region pandocPipeTable start=/\%#=2\([+|]\n\)\@<!\n\@1<=|\(.*|\)\@=/ end=/|.*\n\(\n\|{\)/ containedin=ALLBUT,pandocDelimitedCodeBlock,pandocYAMLHeader keepend
370370
" without beginning and end pipes
371371
syn region pandocPipeTable start=/\%#=2^.*\n-.\{-}|/ end=/|.*\n\n/ keepend
372372
syn match pandocPipeTableDelims /[\|\-:+]/ contained containedin=pandocPipeTable
@@ -380,7 +380,7 @@ syn match pandocTableHeaderWord /\<.\{-}\>/ contained containedin=pandocGridTabl
380380
syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\([ ]\{4,}\|\t\)\=\~\{3,}\~*\)/ end=/^\z1\~*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend
381381
syn region pandocDelimitedCodeBlock start=/^\(>\s\)\?\z(\([ ]\{4,}\|\t\)\=`\{3,}`*\)/ end=/^\z1`*/ skipnl contains=pandocDelimitedCodeBlockStart,pandocDelimitedCodeBlockEnd keepend
382382
call s:WithConceal("codeblock_start", 'syn match pandocDelimitedCodeBlockStart /\(\_^\n\_^\(>\s\)\?\([ ]\{4,}\|\t\)\=\)\@<=\(\~\{3,}\~*\|`\{3,}`*\)/ contained containedin=pandocDelimitedCodeBlock nextgroup=pandocDelimitedCodeBlockLanguage', 'conceal cchar='.s:cchars["codelang"])
383-
syn match pandocDelimitedCodeBlockLanguage /\(\s\?\)\@<=.\+\(\_$\)\@=/ contained
383+
syn match pandocDelimitedCodeBlockLanguage /\(\s\?\)\@<=.\+\(\_$\)\@=/ contained
384384
call s:WithConceal("codeblock_delim", 'syn match pandocDelimitedCodeBlockEnd /\(`\{3,}`*\|\~\{3,}\~*\)\(\_$\n\(>\s\)\?\_$\)\@=/ contained containedin=pandocDelimitedCodeBlock', 'conceal cchar='.s:cchars["codeend"])
385385
syn match pandocBlockQuoteinDelimitedCodeBlock '^>' contained containedin=pandocDelimitedCodeBlock
386386
syn match pandocCodePre /<pre>.\{-}<\/pre>/ skipnl
@@ -411,7 +411,7 @@ call s:WithConceal('abbrev', 'syn match pandocAbbreviationTail /\]/ contained co
411411
"
412412
syn match pandocFootnoteID /\[\^[^\]]\+\]/ nextgroup=pandocFootnoteDef
413413
" Inline footnotes
414-
syn region pandocFootnoteDef start=/\^\[/ skip=/\[.\{-}]/ end=/\]/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocStrongEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell,pandocAmpersandEscape skipnl keepend
414+
syn region pandocFootnoteDef start=/\^\[/ skip=/\[.\{-}]/ end=/\]/ contains=pandocReferenceLabel,pandocReferenceURL,pandocLatex,pandocPCite,pandocCiteKey,pandocStrong,pandocEmphasis,pandocStrongEmphasis,pandocNoFormatted,pandocSuperscript,pandocSubscript,pandocStrikeout,pandocEnDash,pandocEmDash,pandocEllipses,pandocBeginQuote,pandocEndQuote,@Spell,pandocAmpersandEscape skipnl keepend
415415
call s:WithConceal("footnote", 'syn match pandocFootnoteDefHead /\^\[/ contained containedin=pandocFootnoteDef', 'conceal cchar='.s:cchars["footnote"])
416416
call s:WithConceal("footnote", 'syn match pandocFootnoteDefTail /\]/ contained containedin=pandocFootnoteDef', 'conceal')
417417

@@ -429,10 +429,10 @@ syn match pandocUListItem /^>\=\s*[*+-]\s\+-\@!.*$/ nextgroup=pandocUListItem,pa
429429
call s:WithConceal('list', 'syn match pandocUListItemBullet /^>\=\s*\zs[*+-]/ contained containedin=pandocUListItem', 'conceal cchar='.s:cchars['li'])
430430

431431
" Ordered lists
432-
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,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID,pandocAmpersandEscape skipempty display
432+
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,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID,pandocAmpersandEscape skipempty display
433433
" support for roman numerals up to 'c'
434434
if g:pandoc#syntax#roman_lists != 0
435-
syn match pandocListItem /^\s*(\?x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}[.)].*$/ nextgroup=pandocListItem,pandocMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation,pandocAutomaticLink skipempty display
435+
syn match pandocListItem /^\s*(\?x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}[.)].*$/ nextgroup=pandocListItem,pandocMathBlock,pandocLaTeXInlineMath,pandocDelimitedCodeBlock,pandocListItemContinuation,pandocAutomaticLink skipempty display
436436
endif
437437
syn match pandocListItemBullet /^(\?.\{-}[.)]/ contained containedin=pandocListItem
438438
syn match pandocListItemBulletId /\(\d\+\|\l\|\#\|@.\{-}\|x\=l\=\(i\{,3}[vx]\=\)\{,3}c\{,3}\)/ contained containedin=pandocListItemBullet

0 commit comments

Comments
 (0)