" Vim syntax file " Language: reStructuredText Documentation Format " Maintainer: Estienne Swart " URL: http://www.sanbi.ac.za/~estienne/vim/syntax/rest.vim " Latest Revision: 2004-04-26 " " A reStructuredText syntax highlighting mode for vim. " (derived somewhat from Nikolai Weibull's " source) "TODO: " 0. Make sure that no syntax highlighting bleeding occurs! " 1. Need to fix up clusters and contains. " 2. Need to validate against restructured.txt.gz and tools/test.txt. " 3. Fixup superfluous matching. " 4. I need to figure out how to keep a running tally of the indentation in order " to enable block definitions, i.e. a block ends when its indentation drops " below that of the existing one. " 5. Define folding patterns for sections, etc. " 6. Setup a completion mode for target references to hyperlinks " Remove any old syntax stuff that was loaded (5.x) or quit when a syntax file " was already loaded (6.x). if version < 600 syntax clear elseif exists("b:current_syntax") finish endif "syn match rstJunk "\\_" "ReStructuredText Text Inline Markup: syn region rstEmphasis start=+\*[^*]+ end=+\*+ syn region rstStrongEmphasis start=+\*\*[^*]+ end=+\*\*+ syn region rstInterpretedText start=+`[^`]+ end=+`+ contains=rstURL syn region rstInlineLiteral start="``" end="``" contains=rstURL "Using a syn region here causes too much to be highlighted. syn region rstSubstitutionReference start=+|\w+ end=+\w|+ skip=+\\|+ "I'm forcing matching of word characters before and after '|' in order to "prevent table matching (this causes messy highlighting) syn region rstGridTable start=/\n\n\s*+\([-=]\|+\)\+/ms=s+2 end=/+\([-=]\|+\)\+\n\s*\n/me=e-2 syn match rstRuler "\(=\|-\|+\)\{3,120}" " syn match rstInlineInternalTarget "_`\_.\{-}`" syn region rstInlineInternalHyperlink start=+_`+ end=+`+ contains=rsturl " this messes up with InterpretedText syn match rstFootnoteReference "\[\%([#*]\|[0-9]\+\|#[a-zA-Z0-9_.-]\+\)\]_" "syn region rstCitationReference start=+\[+ end=+\]_+ "syn match rstCitationReferenceNothing +\[.*\]+ "TODO: fix Citation reference - patterns defined still cause "bleeding" "if end doesn't get matched, catch it first with another pattern - this is ugly??? syn match rstURL "\(acap\|cid\|data\|dav\|fax\|file\|ftp\|gopher\|http\|https\|imap\|ldap\|mailto\|mid\|modem\|news\|nfs\|nntp\|pop\|prospero\|rtsp\|service\|sip\|tel\|telnet\|tip\|urn\|vemmi\|wais\):[-./[:alnum:]_~@]\+" "I need a better regexp for URLs here. This doesn't cater for URLs that are "broken across lines " hyperlinks syn match rstHyperlinks /`[^`]\+`_/ "syn region rstHyperlinks start="`\w" end="`_" syn match rstExternalHyperlinks "\w\+_\w\@!" "This seems to overlap with the ReStructuredText comment?!? "ReStructuredText Sections: syn match rstTitle ".\{2,120}\n\(\.\|=\|-\|=\|`\|:\|'\|\"\|\~\|\^\|_\|\*\|+\|#\|<\|>\)\{3,120}" " [-=`:'"~^_*+#<>] "for some strange reason this only gets highlighted upon refresh "syn match rstTitle "\w.*\n\(=\|-\|+\)\{2,120}" "ReStructuredText Lists: syn match rstEnumeratedList "^\s*\d\{1,3}\.\s" syn match rstBulletedList "^\s*\([+-]\|\*\)\s" " syn match rstBulletedList "^\s*[+-]\|\*\s" "I'm not sure how to include "*" within a range []?!? " this seems to match more than it should :-( syn match rstFieldList ":[^:]\+:\s"me=e-1 contains=rstBibliographicField "still need to add rstDefinitionList rstOptionList "ReStructuredText Preformatting: syn match rstLiteralBlock "::\s*\n" contains=rstGridTable "syn region rstLiteralBlock start=+\(contents\)\@