]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - syntax/asciidoc.vim
0bf51f03eb3e5052e170d75b41cc01512e490936
[config/dotfiles.git] / syntax / asciidoc.vim
1 " 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://www.methods.co.nz/asciidoc/
6 " Licence:      GPL (http://www.gnu.org)
7 " Remarks:      Vim 6 or greater
8 " Limitations:  See 'Appendix E: Vim Syntax Highlighter' in the AsciiDoc 'User
9 "               Guide'.
10
11 if exists("b:current_syntax")
12   finish
13 endif
14
15 syn clear
16 syn sync fromstart
17 syn sync linebreaks=1
18
19 " Run :help syn-priority to review syntax matching priority.
20 syn keyword asciidocToDo TODO FIXME XXX ZZZ
21 syn match asciidocBackslash /\\/
22 syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/
23 syn match asciidocCallout /\\\@<!<\d\{1,2}>/
24 syn match asciidocListBlockDelimiter /^--$/
25 syn match asciidocLineBreak /[ \t]+$/
26 syn match asciidocRuler /^'\{3,}$/
27 syn match asciidocPagebreak /^<\{3,}$/
28 syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/
29 " The tricky part is not triggering on indented list items that are also
30 " preceeded by blank line, handles only bulleted items (see 'Limitations' above
31 " for workarounds).
32 syn region asciidocLiteralParagraph start=/^\n[ \t]\+\(\([^-*. \t] \)\|\(\S\S\)\)/ end=/\(^+\?\s*$\)\@=/
33 syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/
34 syn match asciidocEmail /\\\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_.]\@!/
35 syn match asciidocAttributeRef /\\\@<!{\w\(\w\|-\)*\([=!@#$%?:].*\)\?}/
36 syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/
37
38 " As a damage control measure quoted patterns always terminate at a  blank
39 " line (see 'Limitations' above).
40 syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/
41 syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/
42 syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([ )\n]\)\@!\_.\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
43 syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=]\)\@<=`\([ )\n]\)\@!\_.\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
44 syn match asciidocQuotedUnconstrainedMonospaced /\\\@<!++\S\_.\{-}\(++\|\n\s*\n\)/
45 syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([ )\n]\)\@!\_.\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
46 syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([ )\n]\)\@!\_.\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
47 syn match asciidocQuotedUnconstrainedEmphasized /\\\@<!__\S\_.\{-}\(__\|\n\s*\n\)/
48 syn match asciidocQuotedBold /\(^\|[| \t([.,=\]]\)\@<=\*\([ )\n]\)\@!\_.\{-}\S\(\*\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
49 syn match asciidocQuotedUnconstrainedBold /\\\@<!\*\*\S\_.\{-}\(\*\*\|\n\s*\n\)/
50 "syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=]\)\@<=`\([ )\n]\)\@!\_.\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
51 " Don't allow ` in single quoted (a kludge to stop confusion with `monospaced`).
52 syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=]\)\@<=`\([ )\n]\)\@!\([^`]\|\n\)\{-}[^`\s]\('\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
53 syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=]\)\@<=``\([ )\n]\)\@!\_.\{-}\S\(''\([| \t)[\],.?!;:=]\|$\)\@=\|\n\s*\n\)/
54
55 syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
56 syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/
57
58 syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/
59 syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/
60
61 syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/
62 syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef
63 syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocAttributeRef
64
65 syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE
66 syn match asciidocTwoLineTitle /^[^. +/].*[^.:]\n[-=~^+]\{2,}$/ contains=asciidocQuoted.*,asciidocAttributeRef,asciidocTitleUnderline
67
68 syn match asciidocAttributeList /^\[[^[ \t].*\]$/
69 syn match asciidocQuoteBlockDelimiter /^_\{4,}$/
70 syn match asciidocExampleBlockDelimiter /^=\{4,}$/
71 syn match asciidocSidebarDelimiter /^*\{4,}$/
72
73 "See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region
74 "contents from highlighting.
75 syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained
76 syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL
77 syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained
78 syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL
79
80 syn match asciidocListContinuation /^+$/
81 syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout keepend
82 syn region asciidocOpenBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout keepend
83 syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo
84 syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$"
85 " Allowing leading \w characters in the filter delimiter is to accomodate
86 " the pre version 8.2.7 syntax and may be removed in future releases.
87 syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/
88
89 syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@<!<<"\{-}\w\(\w\|-\)*"\?,\?/ end=/\(>>\)\|^$/ contains=asciidocQuoted.* keepend
90 syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{2}\(\w\|-\)\+,\?/ end=/\]\{2}/ keepend
91 syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{3}\(\w\|-\)\+/ end=/\]\{3}/ keepend
92 syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/[\\0-9a-zA-Z]\@<!\w\(\w\|-\)*:\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.* keepend
93 syn region asciidocMacroAttributes matchgroup=asciidocIndexTerm start=/\\\@<!(\{2,3}/ end=/)\{2,3}/ contains=asciidocQuoted.* keepend
94 syn region asciidocMacroAttributes matchgroup=asciidocAttributeMacro start=/\({\(\w\|-\)\+}\)\@<=\[/ skip=/\\\]/ end=/\]/ keepend
95
96 syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo
97
98 syn region asciidocVLabel start=/^\s*/ end=/\(::\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend
99 syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend
100
101 syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline
102
103 highlight link asciidocMacroAttributes Label
104 highlight link asciidocIdMarker Special
105 highlight link asciidocDoubleDollarPassthrough Special
106 highlight link asciidocTriplePlusPassthrough Special
107 highlight link asciidocQuotedSubscript Type
108 highlight link asciidocQuotedSuperscript Type
109 highlight link asciidocOneLineTitle Title
110 highlight link asciidocTwoLineTitle Title
111 highlight link asciidocBlockTitle Title
112 highlight link asciidocRefMacro Macro
113 highlight link asciidocIndexTerm Macro
114 highlight link asciidocMacro Macro
115 highlight link asciidocAttributeMacro Macro
116 highlight link asciidocAnchorMacro Macro
117 highlight link asciidocEmail Macro
118 highlight link asciidocListBullet Label
119 highlight link asciidocListNumber Label
120 highlight link asciidocVLabel Label
121 highlight link asciidocHLabel Label
122 highlight link asciidocTable_OLD Type
123 highlight link asciidocTableDelimiter Label
124 highlight link asciidocTableBlock NONE
125 highlight link asciidocTablePrefix Label
126 highlight link asciidocTableDelimiter2 Label
127 highlight link asciidocTableBlock2 NONE
128 highlight link asciidocTablePrefix2 Label
129 highlight link asciidocListBlockDelimiter Label
130 highlight link asciidocListContinuation Label
131 highlight link asciidocLiteralParagraph Identifier
132 highlight link asciidocQuoteBlockDelimiter Type
133 highlight link asciidocExampleBlockDelimiter Type
134 highlight link asciidocSidebarDelimiter Type
135 highlight link asciidocLiteralBlock Identifier
136 highlight link asciidocOpenBlock Identifier
137 highlight link asciidocPassthroughBlock Identifier
138 highlight link asciidocCommentBlock Comment
139 highlight link asciidocFilterBlock Type
140 highlight link asciidocQuotedBold Special
141 highlight link asciidocQuotedUnconstrainedBold Special
142 highlight link asciidocQuotedEmphasized Type
143 highlight link asciidocQuotedEmphasized2 Type
144 highlight link asciidocQuotedUnconstrainedEmphasized Type
145 highlight link asciidocQuotedMonospaced Identifier
146 highlight link asciidocQuotedMonospaced2 Identifier
147 highlight link asciidocQuotedUnconstrainedMonospaced Identifier
148 highlight link asciidocQuotedSingleQuoted Label
149 highlight link asciidocQuotedDoubleQuoted Label
150 highlight link asciidocToDo Todo
151 highlight link asciidocCommentLine Comment
152 highlight link asciidocAdmonition Special
153 highlight link asciidocAttributeRef Special
154 highlight link asciidocAttributeList Special
155 highlight link asciidocAttributeEntry Special
156 highlight link asciidocBackslash Special
157 highlight link asciidocEntityRef Special
158 highlight link asciidocCallout Label
159 highlight link asciidocLineBreak Special
160 highlight link asciidocRuler Type
161 highlight link asciidocPagebreak Type
162 highlight link asciidocURL Macro
163
164 let b:current_syntax = "asciidoc"
165
166 " vim: wrap et sw=2 sts=2: