1" Vim syntax file 2" Language: FlexWiki, http://www.flexwiki.com/ 3" Maintainer: George V. Reilly <george@reilly.org> 4" Home: http://www.georgevreilly.com/vim/flexwiki/ 5" Other Home: http://www.vim.org/scripts/script.php?script_id=1529 6" Author: George V. Reilly 7" Filenames: *.wiki 8" Last Change: Wed Apr 26 11:00 PM 2006 P 9" Version: 0.3 10 11" Note: The horrible regexps were reverse-engineered from 12" FlexWikiCore\EngineSource\Formatter.cs, with help from the Regex Analyzer 13" in The Regulator, http://regulator.sourceforge.net/ .NET uses Perl-style 14" regexes, which use a different syntax than Vim (fewer \s). 15" The primary test case is FlexWiki\FormattingRules.wiki 16 17" Quit if syntax file is already loaded 18if version < 600 19 syntax clear 20elseif exists("b:current_syntax") 21 finish 22endif 23 24" A WikiWord (unqualifiedWikiName) 25syntax match flexwikiWord /\%(_\?\([A-Z]\{2,}[a-z0-9]\+[A-Za-z0-9]*\)\|\([A-Z][a-z0-9]\+[A-Za-z0-9]*[A-Z]\+[A-Za-z0-9]*\)\)/ 26" A [bracketed wiki word] 27syntax match flexwikiWord /\[[[:alnum:]\s]\+\]/ 28 29" text: "this is a link (optional tooltip)":http://www.microsoft.com 30" TODO: check URL syntax against RFC 31syntax match flexwikiLink `\("[^"(]\+\((\([^)]\+\))\)\?":\)\?\(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\(\(\(//\)\|\(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+-=.&\-\\\\]*\)` 32 33" text: *strong* 34syntax match flexwikiBold /\(^\|\W\)\zs\*\([^ ].\{-}\)\*/ 35" '''bold''' 36syntax match flexwikiBold /'''\([^'].\{-}\)'''/ 37 38" text: _emphasis_ 39syntax match flexwikiItalic /\(^\|\W\)\zs_\([^ ].\{-}\)_/ 40" ''italic'' 41syntax match flexwikiItalic /''\([^'].\{-}\)''/ 42 43" ``deemphasis`` 44syntax match flexwikiDeEmphasis /``\([^`].\{-}\)``/ 45 46" text: @code@ 47syntax match flexwikiCode /\(^\|\s\|(\|\[\)\zs@\([^@]\+\)@/ 48 49" text: -deleted text- 50syntax match flexwikiDelText /\(^\|\s\+\)\zs-\([^ <a ]\|[^ <img ]\|[^ -].*\)-/ 51 52" text: +inserted text+ 53syntax match flexwikiInsText /\(^\|\W\)\zs+\([^ ].\{-}\)+/ 54 55" text: ^superscript^ 56syntax match flexwikiSuperScript /\(^\|\W\)\zs^\([^ ].\{-}\)^/ 57 58" text: ~subscript~ 59syntax match flexwikiSubScript /\(^\|\W\)\zs\~\([^ ].\{-}\)\~/ 60 61" text: ??citation?? 62syntax match flexwikiCitation /\(^\|\W\)\zs??\([^ ].\{-}\)??/ 63 64" Emoticons: must come after the Textilisms, as later rules take precedence 65" over earlier ones. This match is an approximation for the ~70 distinct 66" patterns that FlexWiki knows. 67syntax match flexwikiEmoticons /\((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/ 68 69" Aggregate all the regular text highlighting into flexwikiText 70syntax cluster flexwikiText contains=flexwikiItalic,flexwikiBold,flexwikiCode,flexwikiDeEmphasis,flexwikiDelText,flexwikiInsText,flexwikiSuperScript,flexwikiSubScript,flexwikiCitation,flexwikiLink,flexwikiWord,flexwikiEmoticons 71 72" single-line WikiPropertys 73syntax match flexwikiSingleLineProperty /^:\?[A-Z_][_a-zA-Z0-9]\+:/ 74 75" TODO: multi-line WikiPropertys 76 77" Header levels, 1-6 78syntax match flexwikiH1 /^!.*$/ 79syntax match flexwikiH2 /^!!.*$/ 80syntax match flexwikiH3 /^!!!.*$/ 81syntax match flexwikiH4 /^!!!!.*$/ 82syntax match flexwikiH5 /^!!!!!.*$/ 83syntax match flexwikiH6 /^!!!!!!.*$/ 84 85" <hr>, horizontal rule 86syntax match flexwikiHR /^----.*$/ 87 88" Formatting can be turned off by ""enclosing it in pairs of double quotes"" 89syntax match flexwikiEscape /"".\{-}""/ 90 91" Tables. Each line starts and ends with '||'; each cell is separated by '||' 92syntax match flexwikiTable /||/ 93 94" Bulleted list items start with one or tabs, followed by whitespace, then '*' 95" Numeric list items start with one or tabs, followed by whitespace, then '1.' 96" Eight spaces at the beginning of the line is equivalent to the leading tab. 97syntax match flexwikiList /^\(\t\| \{8}\)\s*\(\*\|1\.\).*$/ contains=@flexwikiText 98 99" Treat all other lines that start with spaces as PRE-formatted text. 100syntax match flexwikiPre /^[ \t]\+[^ \t*1].*$/ 101 102 103" Link FlexWiki syntax items to colors 104hi def link flexwikiH1 Title 105hi def link flexwikiH2 flexwikiH1 106hi def link flexwikiH3 flexwikiH2 107hi def link flexwikiH4 flexwikiH3 108hi def link flexwikiH5 flexwikiH4 109hi def link flexwikiH6 flexwikiH5 110hi def link flexwikiHR flexwikiH6 111 112hi def flexwikiBold term=bold cterm=bold gui=bold 113hi def flexwikiItalic term=italic cterm=italic gui=italic 114 115hi def link flexwikiCode Statement 116hi def link flexwikiWord Underlined 117 118hi def link flexwikiEscape Todo 119hi def link flexwikiPre PreProc 120hi def link flexwikiLink Underlined 121hi def link flexwikiList Type 122hi def link flexwikiTable Type 123hi def link flexwikiEmoticons Constant 124hi def link flexwikiDelText Comment 125hi def link flexwikiDeEmphasis Comment 126hi def link flexwikiInsText Constant 127hi def link flexwikiSuperScript Constant 128hi def link flexwikiSubScript Constant 129hi def link flexwikiCitation Constant 130 131hi def link flexwikiSingleLineProperty Identifier 132 133let b:current_syntax="FlexWiki" 134 135" vim:tw=0: 136