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