diff options
author | Stuart Rackham <srackham@methods.co.nz> | 2009-12-05 08:54:13 +1300 |
---|---|---|
committer | Stuart Rackham <srackham@methods.co.nz> | 2009-12-05 08:54:13 +1300 |
commit | 7b38a061a40f5e391b9d85465b652cb29cd21f93 (patch) | |
tree | 2550316aebb0ab56942db8b4730e0cd62e1bed9c | |
parent | 64f982f7f726c6a22eac16ad95542f0ea5251323 (diff) | |
download | asciidoc-7b38a061a40f5e391b9d85465b652cb29cd21f93.tar.gz |
Vim syntax highlighter: Fixed some broken bit viz. lists highlighting,
plus a few other improvements.
-rw-r--r-- | doc/asciidoc.txt | 47 | ||||
-rw-r--r-- | vim/syntax/asciidoc.vim | 138 |
2 files changed, 77 insertions, 108 deletions
diff --git a/doc/asciidoc.txt b/doc/asciidoc.txt index d764db0..fc49360 100644 --- a/doc/asciidoc.txt +++ b/doc/asciidoc.txt @@ -1682,7 +1682,6 @@ labitur dolorum an. Est ne magna primis adolescens. Stylesheets>> and <<X31,dblatex>> process them correctly). - The label width can be set as a percentage of the total width by setting the 'width' attribute e.g. `width="10%"` - ===================================================================== Question and Answer Lists @@ -2293,7 +2292,6 @@ single-file XHTML documents with embedded images and CSS, for example: NOTE: All current popular browsers support 'data URIs', although versions of Internet Explorer prior to version 8 do not support 'data URIs'. - ********************************************************************* [[X25]] @@ -2442,7 +2440,6 @@ header you need to use attribute references to control inclusion instead of conditional inclusion macros (attribute references are substituted at the time the output is written rather than at program startup). - ********************************************************************* Executable system macros @@ -2865,7 +2862,6 @@ facilitate their use, uses proportional column widths (by defaulting the AsciiDoc 'pageunits' attribute to '*'). To generate DocBook tables with fixed widths set 'pageunits' to a CALS absolute unit such as 'pt'. - ********************************************************************* [[X70]] @@ -3097,7 +3093,6 @@ PostScript to PDF using `ps2pdf(1)`: $ man -l -Tps asciidoc.1 | ps2pdf - asciidoc.1.pdf The `ps2pdf(1)` command is included in the Ghostscript distribution. - ********************************************************************** To find out more about man pages view the `man(7)` manpage @@ -3771,7 +3766,6 @@ and write, here are some examples: arbitrary lines of text can be abbreviated. - Shared attributes entries could be grouped into a separate file and <<X63,included>> in multiple documents. - ********************************************************************* @@ -4806,7 +4800,6 @@ Execute `:help gq` command to read about the vim gq command. - The Vim website (http://www.vim.org) has a wealth of resources, including scripts for automated spell checking and ASCII Art drawing. - ===================================================================== Format Lists @@ -5119,6 +5112,7 @@ formed. :numbered!: +[glossary] Glossary -------- [glossary] @@ -5275,39 +5269,17 @@ for emacs]. Limitations ~~~~~~~~~~~ The current implementation does a reasonable job but on occasions gets -things wrong. This list of limitations also discusses how to work -around the problems: - -- Indented lists with preceding blank lines are sometimes mistaken - for literal (indented) paragraphs. You can work around this by - deleting the preceding blank line, or inserting a space in the - preceding blank lines, or putting a list continuation character - (`+`) in the preceding blank line. +things wrong: - Nested quoted text formatting is highlighted according to the outer format. - -- If a closing block delimiter is not preceded by a blank line it is - sometimes mistaken for a title underline. A workaround is to insert - a blank line before the closing delimiter. - -- If a list block delimiter is mistaken for a title underline precede - it with a blank line. - -- Lines within a paragraph beginning with a period will be highlighted - as block titles. For example: - - .chm file. -+ -To work around this restriction move the last word of the previous -line to the start of the current (although words starting with a -period should probably be quoted monospace which would also get around -the problem). - -TIP: Sometimes incorrect highlighting is caused by preceding lines -that appear blank but contain white space characters -- setting your -editor options so that white space characters are visible is a good -idea. +- If a closing Example Block delimiter is sometimes mistaken for a + title underline. A workaround is to insert a blank line before the + closing delimiter. +- Lines within a paragraph starting with equals characters may be + highlighted as single-line titles. +- Lines within a paragraph beginning with a period may be highlighted + as block titles. [[X74]] @@ -5347,7 +5319,6 @@ width of the page irrespective of the current indentation. |strong |xhtml11,html4 |labeled lists| Emboldens label text. - |==================================================================== diff --git a/vim/syntax/asciidoc.vim b/vim/syntax/asciidoc.vim index 6e83280..c30a6ee 100644 --- a/vim/syntax/asciidoc.vim +++ b/vim/syntax/asciidoc.vim @@ -17,7 +17,7 @@ syn sync fromstart syn sync linebreaks=1 " Run :help syn-priority to review syntax matching priority. -syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ +syn keyword asciidocToDo TODO FIXME CHECK TEST XXX ZZZ DEPRECATED syn match asciidocBackslash /\\/ syn region asciidocIdMarker start=/^\$Id:\s/ end=/\s\$$/ syn match asciidocCallout /\\\@<!<\d\{1,2}>/ @@ -26,24 +26,19 @@ syn match asciidocLineBreak /[ \t]+$/ syn match asciidocRuler /^'\{3,}$/ syn match asciidocPagebreak /^<\{3,}$/ syn match asciidocEntityRef /\\\@<!&[#a-zA-Z]\S\{-};/ -" asciidocLiteralParagraph is broken by: -" - Preceding attribute lists. -" - Indented lists (accept those with single '-', '*' or '.' bullet -" characters). -syn region asciidocLiteralParagraph start=/^\n[ \t]\+\(\([^-*.] \)\|\(\S\S\)\)/ end=/\(^+\?\s*$\)\@=/ +syn region asciidocLiteralParagraph start=/^\s\+\S\+/ end=/\(^+\?\s*$\)\@=/ syn match asciidocURL /\\\@<!\<\(http\|https\|ftp\|file\|irc\):\/\/[^| \t]*\(\w\|\/\)/ -syn match asciidocEmail /\\\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/ +syn match asciidocEmail /[\\.:]\@<!\(\<\|<\)\w\(\w\|[.-]\)*@\(\w\|[.-]\)*\w>\?[0-9A-Za-z_]\@!/ syn match asciidocAttributeRef /\\\@<!{\w\(\w\|-\)*\([=!@#$%?:].*\)\?}/ -syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/ -" As a damage control measure quoted patterns always terminate at a blank +" As a damage control measure quoted patterns always terminate at a blank " line (see 'Limitations' above). syn match asciidocQuotedSubscript /\\\@<!\~\S\_.\{-}\(\~\|\n\s*\n\)/ syn match asciidocQuotedSuperscript /\\\@<!\^\S\_.\{-}\(\^\|\n\s*\n\)/ syn match asciidocQuotedMonospaced /\(^\|[| \t([.,=\]]\)\@<=+\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(+\([| \t)[\],.?!;:=]\|$\)\@=\)/ syn match asciidocQuotedMonospaced2 /\(^\|[| \t([.,=\]]\)\@<=`\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(`\([| \t)[\],.?!;:=]\|$\)\@=\)/ -syn match asciidocQuotedUnconstrainedMonospaced /\\\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ +syn match asciidocQuotedUnconstrainedMonospaced /[\\+]\@<!++\S\_.\{-}\(++\|\n\s*\n\)/ syn match asciidocQuotedEmphasized /\(^\|[| \t([.,=\]]\)\@<=_\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\(_\([| \t)[\],.?!;:=]\|$\)\@=\)/ syn match asciidocQuotedEmphasized2 /\(^\|[| \t([.,=\]]\)\@<='\([ )\n\t]\)\@!\(.\|\n\(\s*\n\)\@!\)\{-}\S\('\([| \t)[\],.?!;:=]\|$\)\@=\)/ @@ -60,23 +55,21 @@ syn match asciidocQuotedDoubleQuoted /\(^\|[| \t([.,=]\)\@<=``\([ )\n\t]\)\@!\(. syn match asciidocDoubleDollarPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=\$\$..\{-}\(\$\$\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/ syn match asciidocTriplePlusPassthrough /\\\@<!\(^\|[^0-9a-zA-Z$]\)\@<=+++..\{-}\(+++\([^0-9a-zA-Z$]\|$\)\@=\|^$\)/ -syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/ -syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/ +syn match asciidocAdmonition /^\u\{3,15}:\(\s\+.*\)\@=/ syn region asciidocTable_OLD start=/^\([`.']\d*[-~_]*\)\+[-~_]\+\d*$/ end=/^$/ syn match asciidocBlockTitle /^\.[^. \t].*[^-~_]$/ contains=asciidocQuoted.*,asciidocAttributeRef -syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocAttributeRef - syn match asciidocTitleUnderline /[-=~^+]\{2,}$/ transparent contained contains=NONE -syn match asciidocTwoLineTitle /^[^. +/].*[^.:]\n[-=~^+]\{2,}$/ contains=asciidocQuoted.*,asciidocAttributeRef,asciidocTitleUnderline +syn match asciidocOneLineTitle /^=\{1,5}\s\+\S.*$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash +syn match asciidocTwoLineTitle /^[^. +/].*[^.]\n[-=~^+]\{2,}$/ contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash,asciidocTitleUnderline syn match asciidocAttributeList /^\[[^[ \t].*\]$/ syn match asciidocQuoteBlockDelimiter /^_\{4,}$/ syn match asciidocExampleBlockDelimiter /^=\{4,}$/ syn match asciidocSidebarDelimiter /^*\{4,}$/ -"See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region -"contents from highlighting. +" See http://vimdoc.sourceforge.net/htmldoc/usr_44.html for excluding region +" contents from highlighting. syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?|/ containedin=asciidocTableBlock contained syn region asciidocTableBlock matchgroup=asciidocTableDelimiter start=/^|=\{3,}$/ end=/^|=\{3,}$/ keepend contains=ALL syn match asciidocTablePrefix /\(\S\@<!\(\([0-9.]\+\)\([*+]\)\)\?\([<\^>.]\{,3}\)\?\([a-z]\)\?\)\?!/ containedin=asciidocTableBlock contained @@ -84,9 +77,10 @@ syn region asciidocTableBlock2 matchgroup=asciidocTableDelimiter2 start=/^!=\{3, syn match asciidocListContinuation /^+$/ syn region asciidocLiteralBlock start=/^\.\{4,}$/ end=/^\.\{4,}$/ contains=asciidocCallout keepend -syn region asciidocOpenBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout keepend +syn region asciidocListingBlock start=/^-\{4,}$/ end=/^-\{4,}$/ contains=asciidocCallout keepend syn region asciidocCommentBlock start="^/\{4,}$" end="^/\{4,}$" contains=asciidocToDo syn region asciidocPassthroughBlock start="^+\{4,}$" end="^+\{4,}$" + " Allowing leading \w characters in the filter delimiter is to accomodate " the pre version 8.2.7 syntax and may be removed in future releases. syn region asciidocFilterBlock start=/^\w*\~\{4,}$/ end=/^\w*\~\{4,}$/ @@ -100,73 +94,77 @@ syn region asciidocMacroAttributes matchgroup=asciidocAttributeMacro start=/\({\ syn match asciidocCommentLine "^//\([^/].*\|\)$" contains=asciidocToDo -syn region asciidocLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend -"DEPRECATED: Horizontal label. -syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend - syn region asciidocAttributeEntry start=/^:\w/ end=/:\(\s\|$\)/ oneline -highlight link asciidocMacroAttributes Label -highlight link asciidocIdMarker Special -highlight link asciidocDoubleDollarPassthrough Special -highlight link asciidocTriplePlusPassthrough Special -highlight link asciidocQuotedSubscript Type -highlight link asciidocQuotedSuperscript Type -highlight link asciidocOneLineTitle Title -highlight link asciidocTwoLineTitle Title -highlight link asciidocBlockTitle Title -highlight link asciidocRefMacro Macro -highlight link asciidocIndexTerm Macro -highlight link asciidocMacro Macro -highlight link asciidocAttributeMacro Macro +" Lists. +syn match asciidocListBullet /^\s*\zs\(-\|\*\{1,5}\)\ze\s/ +syn match asciidocListNumber /^\s*\zs\(\(\d\+\.\)\|\.\{1,5}\|\(\a\.\)\|\([ivxIVX]\+)\)\)\ze\s\+/ +syn region asciidocListLabel start=/^\s*/ end=/\(:\{2,4}\|;;\)$/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes,asciidocAttributeRef,asciidocEntityRef,asciidocEmail,asciidocURL,asciidocBackslash keepend +" DEPRECATED: Horizontal label. +syn region asciidocHLabel start=/^\s*/ end=/\(::\|;;\)\(\s\+\|\\$\)/ oneline contains=asciidocQuoted.*,asciidocMacroAttributes keepend +" Starts with any of the above. +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 + +highlight link asciidocAdmonition Special highlight link asciidocAnchorMacro Macro +highlight link asciidocAttributeEntry Special +highlight link asciidocAttributeList Special +highlight link asciidocAttributeMacro Macro +highlight link asciidocAttributeRef Special +highlight link asciidocBackslash Special +highlight link asciidocBlockTitle Title +highlight link asciidocCallout Label +highlight link asciidocCommentBlock Comment +highlight link asciidocCommentLine Comment +highlight link asciidocDoubleDollarPassthrough Special highlight link asciidocEmail Macro -highlight link asciidocListBullet Label -highlight link asciidocListNumber Label -highlight link asciidocLabel Label +highlight link asciidocEntityRef Special +highlight link asciidocExampleBlockDelimiter Type +highlight link asciidocFilterBlock Type highlight link asciidocHLabel Label -highlight link asciidocTable_OLD Type -highlight link asciidocTableDelimiter Label -highlight link asciidocTableBlock NONE -highlight link asciidocTablePrefix Label -highlight link asciidocTableDelimiter2 Label -highlight link asciidocTableBlock2 NONE -highlight link asciidocTablePrefix2 Label +highlight link asciidocIdMarker Special +highlight link asciidocIndexTerm Macro +highlight link asciidocLineBreak Special highlight link asciidocListBlockDelimiter Label +highlight link asciidocListBullet Label highlight link asciidocListContinuation Label -highlight link asciidocLiteralParagraph Identifier -highlight link asciidocQuoteBlockDelimiter Type -highlight link asciidocExampleBlockDelimiter Type -highlight link asciidocSidebarDelimiter Type +highlight link asciidocListingBlock Identifier +highlight link asciidocListLabel Label +highlight link asciidocListNumber Label highlight link asciidocLiteralBlock Identifier -highlight link asciidocOpenBlock Identifier +highlight link asciidocLiteralParagraph Identifier +highlight link asciidocMacroAttributes Label +highlight link asciidocMacro Macro +highlight link asciidocOneLineTitle Title +highlight link asciidocPagebreak Type highlight link asciidocPassthroughBlock Identifier -highlight link asciidocCommentBlock Comment -highlight link asciidocFilterBlock Type +highlight link asciidocQuoteBlockDelimiter Type highlight link asciidocQuotedBold Special -highlight link asciidocQuotedUnconstrainedBold Special -highlight link asciidocQuotedEmphasized Type +highlight link asciidocQuotedDoubleQuoted Label highlight link asciidocQuotedEmphasized2 Type -highlight link asciidocQuotedUnconstrainedEmphasized Type -highlight link asciidocQuotedMonospaced Identifier +highlight link asciidocQuotedEmphasized Type highlight link asciidocQuotedMonospaced2 Identifier -highlight link asciidocQuotedUnconstrainedMonospaced Identifier +highlight link asciidocQuotedMonospaced Identifier highlight link asciidocQuotedSingleQuoted Label -highlight link asciidocQuotedDoubleQuoted Label -highlight link asciidocToDo Todo -highlight link asciidocCommentLine Comment -highlight link asciidocAdmonition Special -highlight link asciidocAttributeRef Special -highlight link asciidocAttributeList Special -highlight link asciidocAttributeEntry Special -highlight link asciidocBackslash Special -highlight link asciidocEntityRef Special -highlight link asciidocCallout Label -highlight link asciidocLineBreak Special +highlight link asciidocQuotedSubscript Type +highlight link asciidocQuotedSuperscript Type +highlight link asciidocQuotedUnconstrainedBold Special +highlight link asciidocQuotedUnconstrainedEmphasized Type +highlight link asciidocQuotedUnconstrainedMonospaced Identifier +highlight link asciidocRefMacro Macro highlight link asciidocRuler Type -highlight link asciidocPagebreak Type +highlight link asciidocSidebarDelimiter Type +highlight link asciidocTableBlock2 NONE +highlight link asciidocTableBlock NONE +highlight link asciidocTableDelimiter2 Label +highlight link asciidocTableDelimiter Label +highlight link asciidocTable_OLD Type +highlight link asciidocTablePrefix2 Label +highlight link asciidocTablePrefix Label +highlight link asciidocToDo Todo +highlight link asciidocTriplePlusPassthrough Special +highlight link asciidocTwoLineTitle Title highlight link asciidocURL Macro - let b:current_syntax = "asciidoc" " vim: wrap et sw=2 sts=2: |