Bram Moolenaar | ac7bd63 | 2013-03-19 11:35:58 +0100 | [diff] [blame] | 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://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 | |
| 21 | if exists("b:current_syntax") |
| 22 | finish |
| 23 | endif |
| 24 | |
| 25 | syn clear |
| 26 | syn sync fromstart |
| 27 | syn sync linebreaks=100 |
| 28 | |
| 29 | " Run :help syn-priority to review syntax matching priority. |
| 30 | syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED |
| 31 | syn match asciidocBackslash /\\/ |
| 32 | syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/ |
| 33 | syn match asciidocCallout /\\\@<!<\d\{1,2}>/ |
| 34 | syn match asciidocOpenBlockDelimiter /^--$/ |
| 35 | syn match asciidocLineBreak /[ \t]+$/ containedin=asciidocList |
| 36 | syn match asciidocRuler /^'\{3,}$/ |
| 37 | syn match asciidocPagebreak /^<\{3,}$/ |
| 38 | syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/ |
| 39 | syn region asciidocLiteralParagraph start=/\(\%^\|\_^\s*\n\)\@<=\s\+\S\+/ end=/\(^\(+\|--\)\?\s*$\)\@=/ contains=asciidocToDo |
| 40 | syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/ |
| 41 | syn match asciidocEmail /[\\.:]\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/ |
| 42 | syn match asciidocAttributeRef /\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}/ |
| 43 | |
| 44 | " As a damage control measure quoted patterns always terminate at a blank |
| 45 | " line (see 'Limitations' above). |
| 46 | syn match asciidocQuotedAttributeList /\\\@<!\[[a-zA-Z0-9_-][a-zA-Z0-9 _-]*\][+_'`#*]\@=/ |
| 47 | syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/ contains=asciidocEntityRef |
| 48 | syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/ contains=asciidocEntityRef |
| 49 | |
| 50 | syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([+ \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef |
| 51 | syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=\]]\)\@<=`\([` \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\)/ |
| 52 | syn match asciidocQuotedUnconstrainedMonospaced /[\\+]\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ contains=asciidocEntityRef |
| 53 | |
| 54 | syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([_ \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef |
| 55 | syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([' \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef |
| 56 | syn match asciidocQuotedUnconstrainedEmphasized /\\\@<!__\S\_.\{-}\(__\|\n\s*\n\)/ contains=asciidocEntityRef |
| 57 | |
| 58 | syn match asciidocQuotedBold /\(^\|[| \t([.,=\]]\)\@<=\*\([* \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(\*\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef |
| 59 | syn match asciidocQuotedUnconstrainedBold /\\\@<!\*\*\S\_.\{-}\(\*\*\|\n\s*\n\)/ contains=asciidocEntityRef |
| 60 | |
| 61 | " Don't allow ` in single quoted (a kludge to stop confusion with `monospaced`). |
| 62 | syn match asciidocQuotedSingleQuoted /\(^\|[| \t([.,=\]]\)\@<=`\([` \n\t]\)\@!\([^`]\|\n\(\s*\n\)\@!\)\{-}[^` \t]\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef |
| 63 | |
| 64 | syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=\]]\)\@<=``\([` \n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(''\([| \t)[\],.?!;:=]\|$\)\@=\)/ contains=asciidocEntityRef |
| 65 | |
| 66 | syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/ |
| 67 | syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/ |
| 68 | |
| 69 | syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/ |
| 70 | |
| 71 | syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/ |
| 72 | syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef |
| 73 | syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE |
| 74 | syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash |
| 75 | syn match asciidocTwoLineTitle /^[^. +/].*[^.]\n[-=~^+]\{3,}$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocTitleUnderline |
| 76 | |
| 77 | syn match asciidocAttributeList /^\[[^[ \t].*\]$/ |
| 78 | syn match asciidocQuoteBlockDelimiter /^_\{4,}$/ |
| 79 | syn match asciidocExampleBlockDelimiter /^=\{4,}$/ |
| 80 | syn match asciidocSidebarDelimiter /^*\{4,}$/ |
| 81 | |
| 82 | " See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region |
| 83 | " contents from highlighting. |
| 84 | syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained |
| 85 | syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL |
| 86 | syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained |
| 87 | syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3,}$/ end=/^!=\{3,}$/ keepend contains=ALL |
| 88 | |
| 89 | syn match asciidocListContinuation /^+$/ |
| 90 | syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout,asciidocToDo keepend |
| 91 | syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout,asciidocToDo keepend |
| 92 | syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo |
| 93 | syn 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. |
| 97 | syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/ |
| 98 | |
| 99 | syn region asciidocMacroAttributes matchgroup=asciidocRefMacro start=/\\\@<!<<"\{-}\(\w\|-\|_\|:\|\.\)\+"\?,\?/ end=/\(>>\)\|^$/ contains=asciidocQuoted.* keepend |
| 100 | syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{2}\(\w\|-\|_\|:\|\.\)\+,\?/ end=/\]\{2}/ keepend |
| 101 | syn region asciidocMacroAttributes matchgroup=asciidocAnchorMacro start=/\\\@<!\[\{3}\(\w\|-\|_\|:\|\.\)\+/ end=/\]\{3}/ keepend |
| 102 | syn 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). |
| 104 | syn region asciidocMacroAttributes matchgroup=asciidocMacro start=/\(\\\@<!{\w\(\w\|[-,+]\)*\([=!@#$%?:].*\)\?}\)\@<=\S\{-}\[/ skip=/\\\]/ end=/\]\|^$/ contains=asciidocQuoted.*,asciidocAttributeRef keepend |
| 105 | syn region asciidocMacroAttributes matchgroup=asciidocIndexTerm start=/\\\@<!(\{2,3}/ end=/)\{2,3}/ contains=asciidocQuoted.*,asciidocAttributeRef keepend |
| 106 | |
| 107 | syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo |
| 108 | |
| 109 | syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline |
| 110 | |
| 111 | " Lists. |
| 112 | syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/ |
| 113 | syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/ |
| 114 | syn region asciidocListLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocToDo keepend |
| 115 | " DEPRECATED: Horizontal label. |
| 116 | syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend |
| 117 | " Starts with any of the above. |
| 118 | syn 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 | |
| 120 | hi def link asciidocAdmonition Special |
| 121 | hi def link asciidocAnchorMacro Macro |
| 122 | hi def link asciidocAttributeEntry Special |
| 123 | hi def link asciidocAttributeList Special |
| 124 | hi def link asciidocAttributeMacro Macro |
| 125 | hi def link asciidocAttributeRef Special |
| 126 | hi def link asciidocBackslash Special |
| 127 | hi def link asciidocBlockTitle Title |
| 128 | hi def link asciidocCallout Label |
| 129 | hi def link asciidocCommentBlock Comment |
| 130 | hi def link asciidocCommentLine Comment |
| 131 | hi def link asciidocDoubleDollarPassthrough Special |
| 132 | hi def link asciidocEmail Macro |
| 133 | hi def link asciidocEntityRef Special |
| 134 | hi def link asciidocExampleBlockDelimiter Type |
| 135 | hi def link asciidocFilterBlock Type |
| 136 | hi def link asciidocHLabel Label |
| 137 | hi def link asciidocIdMarker Special |
| 138 | hi def link asciidocIndexTerm Macro |
| 139 | hi def link asciidocLineBreak Special |
| 140 | hi def link asciidocOpenBlockDelimiter Label |
| 141 | hi def link asciidocListBullet Label |
| 142 | hi def link asciidocListContinuation Label |
| 143 | hi def link asciidocListingBlock Identifier |
| 144 | hi def link asciidocListLabel Label |
| 145 | hi def link asciidocListNumber Label |
| 146 | hi def link asciidocLiteralBlock Identifier |
| 147 | hi def link asciidocLiteralParagraph Identifier |
| 148 | hi def link asciidocMacroAttributes Label |
| 149 | hi def link asciidocMacro Macro |
| 150 | hi def link asciidocOneLineTitle Title |
| 151 | hi def link asciidocPagebreak Type |
| 152 | hi def link asciidocPassthroughBlock Identifier |
| 153 | hi def link asciidocQuoteBlockDelimiter Type |
| 154 | hi def link asciidocQuotedAttributeList Special |
| 155 | hi def link asciidocQuotedBold Special |
| 156 | hi def link asciidocQuotedDoubleQuoted Label |
| 157 | hi def link asciidocQuotedEmphasized2 Type |
| 158 | hi def link asciidocQuotedEmphasized Type |
| 159 | hi def link asciidocQuotedMonospaced2 Identifier |
| 160 | hi def link asciidocQuotedMonospaced Identifier |
| 161 | hi def link asciidocQuotedSingleQuoted Label |
| 162 | hi def link asciidocQuotedSubscript Type |
| 163 | hi def link asciidocQuotedSuperscript Type |
| 164 | hi def link asciidocQuotedUnconstrainedBold Special |
| 165 | hi def link asciidocQuotedUnconstrainedEmphasized Type |
| 166 | hi def link asciidocQuotedUnconstrainedMonospaced Identifier |
| 167 | hi def link asciidocRefMacro Macro |
| 168 | hi def link asciidocRuler Type |
| 169 | hi def link asciidocSidebarDelimiter Type |
| 170 | hi def link asciidocTableBlock2 NONE |
| 171 | hi def link asciidocTableBlock NONE |
| 172 | hi def link asciidocTableDelimiter2 Label |
| 173 | hi def link asciidocTableDelimiter Label |
| 174 | hi def link asciidocTable_OLD Type |
| 175 | hi def link asciidocTablePrefix2 Label |
| 176 | hi def link asciidocTablePrefix Label |
| 177 | hi def link asciidocToDo Todo |
| 178 | hi def link asciidocTriplePlusPassthrough Special |
| 179 | hi def link asciidocTwoLineTitle Title |
| 180 | hi def link asciidocURL Macro |
| 181 | let b:current_syntax = "asciidoc" |
| 182 | |
| 183 | " vim: wrap et sw=2 sts=2: |