blob: 1303db7cf279eb27b0e6f72cdb3cba239de23f87 [file] [log] [blame]
Bram Moolenaarac7bd632013-03-19 11:35:58 +01001" Vim syntax file
2" Language: AsciiDoc
3" Author: Stuart Rackham <srackham@gmail.com> (inspired by Felix
4" Obenhuber's original asciidoc.vim script).
5" URL: http://asciidoc.org/
6" Licence: GPL (http://www.gnu.org)
7" Remarks: Vim 6 or greater
8" Limitations:
9"
10" - Nested quoted text formatting is highlighted according to the outer
11" format.
12" - If a closing Example Block delimiter may be mistaken for a title
13" underline. A workaround is to insert a blank line before the closing
14" delimiter.
15" - Lines within a paragraph starting with equals characters are
16" highlighted as single-line titles.
17" - Lines within a paragraph beginning with a period are highlighted as
18" block titles.
19
20
21if exists("b:current_syntax")
22 finish
23endif
24
25syn clear
26syn sync fromstart
27syn sync linebreaks=100
28
29" Run :help syn-priority to review syntax matching priority.
30syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED
31syn match asciidocBackslash /\\/
32syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/
33syn match asciidocCallout /\\\@<!<\d\{1,2}>/
34syn match asciidocOpenBlockDelimiter /^--$/
35syn match asciidocLineBreak /[ \t]+$/ containedin=asciidocList
36syn match asciidocRuler /^'\{3,}$/
37syn match asciidocPagebreak /^<\{3,}$/
38syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/
39syn region asciidocLiteralParagraph start=/\(\%^\|\_^\s*\n\)\@<=\s\+\S\+/ end=/\(^\(+\|--\)\?\s*$\)\@=/ contains=asciidocToDo
40syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/
41syn match asciidocEmail /[\\.:]\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/
42syn match asciidocAttributeRef /\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}/
43
44" As a damage control measure quoted patterns always terminate at a blank
45" line (see 'Limitations' above).
46syn match asciidocQuotedAttributeList /\\\@<!\[[a-zA-Z0-9_-][a-zA-Z0-9 _-]*\][+_'`#*]\@=/
47syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/ contains=asciidocEntityRef
48syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/ contains=asciidocEntityRef
49
50syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([+ \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
51syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=\]]\)\@<=`\([` \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\)/
52syn match asciidocQuotedUnconstrainedMonospaced /[\\+]\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ contains=asciidocEntityRef
53
54syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([_ \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
55syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([' \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
56syn match asciidocQuotedUnconstrainedEmphasized /\\\@<!__\S\_.\{-}\(__\|\n\s*\n\)/ contains=asciidocEntityRef
57
58syn match asciidocQuotedBold /\(^\|[| \t([.,=\]]\)\@<=\*\([* \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(\*\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
59syn match asciidocQuotedUnconstrainedBold /\\\@<!\*\*\S\_.\{-}\(\*\*\|\n\s*\n\)/ contains=asciidocEntityRef
60
61" Don't allow ` in single quoted (a kludge to stop confusion with `monospaced`).
62syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=\]]\)\@<=`\([` \n\t]\)\@!\([^`]\|\n\(\s*\n\)\@!\)\{-}[^` \t]\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
63
64syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=\]]\)\@<=``\([` \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(''\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef
65
66syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
67syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
68
69syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/
70
71syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/
72syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef
73syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE
74syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash
75syn match asciidocTwoLineTitle /^[^. +/].*[^.]\n[-=~^+]\{3,}$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocTitleUnderline
76
77syn match asciidocAttributeList /^\[[^[ \t].*\]$/
78syn match asciidocQuoteBlockDelimiter /^_\{4,}$/
79syn match asciidocExampleBlockDelimiter /^=\{4,}$/
80syn match asciidocSidebarDelimiter /^*\{4,}$/
81
82" See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region
83" contents from highlighting.
84syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained
85syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL
86syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained
87syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL
88
89syn match asciidocListContinuation /^+$/
90syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
91syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout,asciidocToDo keepend
92syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo
93syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$"
94
95" Allowing leading \w characters in the filter delimiter is to accomodate
96" the pre version 8.2.7 syntax and may be removed in future releases.
97syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/
98
99syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@<!<<"\{-}\(\w\|-\|_\|:\|\.\)\+"\?,\?/ end=/\(>>\)\|^$/ contains=asciidocQuoted.* keepend
100syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{2}\(\w\|-\|_\|:\|\.\)\+,\?/ end=/\]\{2}/ keepend
101syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{3}\(\w\|-\|_\|:\|\.\)\+/ end=/\]\{3}/ keepend
102syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/[\\0-9a-zA-Z]\@<!\w\(\w\|-\)*:\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef,asciidocEntityRef keepend
103" Highlight macro that starts with an attribute reference (a common idiom).
104syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/\(\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}\)\@<=\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
105syn region asciidocMacroAttributes matchgroup=asciidocIndexTerm start=/\\\@<!(\{2,3}/ end=/)\{2,3}/ contains=asciidocQuoted.*,asciidocAttributeRef keepend
106
107syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo
108
109syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline
110
111" Lists.
112syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/
113syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/
114syn region asciidocListLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocToDo keepend
115" DEPRECATED: Horizontal label.
116syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend
117" Starts with any of the above.
118syn region asciidocList start=/^\s*\(-\|\*\{1,5}\)\s/ start=/^\s*\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\s\+/ start=/.\+\(:\{2,4}\|;;\)$/ end=/\(^[=*]\{4,}$\)\@=/ end=/\(^\(+\|--\)\?\s*$\)\@=/ contains=asciidocList.\+,asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocCommentLine,asciidocAttributeList,asciidocToDo
119
120hi def link asciidocAdmonition Special
121hi def link asciidocAnchorMacro Macro
122hi def link asciidocAttributeEntry Special
123hi def link asciidocAttributeList Special
124hi def link asciidocAttributeMacro Macro
125hi def link asciidocAttributeRef Special
126hi def link asciidocBackslash Special
127hi def link asciidocBlockTitle Title
128hi def link asciidocCallout Label
129hi def link asciidocCommentBlock Comment
130hi def link asciidocCommentLine Comment
131hi def link asciidocDoubleDollarPassthrough Special
132hi def link asciidocEmail Macro
133hi def link asciidocEntityRef Special
134hi def link asciidocExampleBlockDelimiter Type
135hi def link asciidocFilterBlock Type
136hi def link asciidocHLabel Label
137hi def link asciidocIdMarker Special
138hi def link asciidocIndexTerm Macro
139hi def link asciidocLineBreak Special
140hi def link asciidocOpenBlockDelimiter Label
141hi def link asciidocListBullet Label
142hi def link asciidocListContinuation Label
143hi def link asciidocListingBlock Identifier
144hi def link asciidocListLabel Label
145hi def link asciidocListNumber Label
146hi def link asciidocLiteralBlock Identifier
147hi def link asciidocLiteralParagraph Identifier
148hi def link asciidocMacroAttributes Label
149hi def link asciidocMacro Macro
150hi def link asciidocOneLineTitle Title
151hi def link asciidocPagebreak Type
152hi def link asciidocPassthroughBlock Identifier
153hi def link asciidocQuoteBlockDelimiter Type
154hi def link asciidocQuotedAttributeList Special
155hi def link asciidocQuotedBold Special
156hi def link asciidocQuotedDoubleQuoted Label
157hi def link asciidocQuotedEmphasized2 Type
158hi def link asciidocQuotedEmphasized Type
159hi def link asciidocQuotedMonospaced2 Identifier
160hi def link asciidocQuotedMonospaced Identifier
161hi def link asciidocQuotedSingleQuoted Label
162hi def link asciidocQuotedSubscript Type
163hi def link asciidocQuotedSuperscript Type
164hi def link asciidocQuotedUnconstrainedBold Special
165hi def link asciidocQuotedUnconstrainedEmphasized Type
166hi def link asciidocQuotedUnconstrainedMonospaced Identifier
167hi def link asciidocRefMacro Macro
168hi def link asciidocRuler Type
169hi def link asciidocSidebarDelimiter Type
170hi def link asciidocTableBlock2 NONE
171hi def link asciidocTableBlock NONE
172hi def link asciidocTableDelimiter2 Label
173hi def link asciidocTableDelimiter Label
174hi def link asciidocTable_OLD Type
175hi def link asciidocTablePrefix2 Label
176hi def link asciidocTablePrefix Label
177hi def link asciidocToDo Todo
178hi def link asciidocTriplePlusPassthrough Special
179hi def link asciidocTwoLineTitle Title
180hi def link asciidocURL Macro
181let b:current_syntax = "asciidoc"
182
183" vim: wrap et sw=2 sts=2: