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
8 " Last Change: Wed Apr 26 11:00 PM 2006 P
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
17 " Quit if syntax file is already loaded
20 elseif exists("b:current_syntax")
24 " A WikiWord (unqualifiedWikiName)
25 syntax 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]
27 syntax match flexwikiWord /\[[[:alnum:]\s]\+\]/
29 " text: "this is a link (optional tooltip)":http://www.microsoft.com
30 " TODO: check URL syntax against RFC
31 syntax match flexwikiLink `\("[^"(]\+\((\([^)]\+\))\)\?":\)\?\(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\(\(\(//\)\|\(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+-=.&\-\\\\]*\)`
34 syntax match flexwikiBold /\(^\|\W\)\zs\*\([^ ].\{-}\)\*/
36 syntax match flexwikiBold /'''\([^'].\{-}\)'''/
39 syntax match flexwikiItalic /\(^\|\W\)\zs_\([^ ].\{-}\)_/
41 syntax match flexwikiItalic /''\([^'].\{-}\)''/
44 syntax match flexwikiDeEmphasis /``\([^`].\{-}\)``/
47 syntax match flexwikiCode /\(^\|\s\|(\|\[\)\zs@\([^@]\+\)@/
49 " text: -deleted text-
50 syntax match flexwikiDelText /\(^\|\s\+\)\zs-\([^ <a ]\|[^ <img ]\|[^ -].*\)-/
52 " text: +inserted text+
53 syntax match flexwikiInsText /\(^\|\W\)\zs+\([^ ].\{-}\)+/
56 syntax match flexwikiSuperScript /\(^\|\W\)\zs^\([^ ].\{-}\)^/
59 syntax match flexwikiSubScript /\(^\|\W\)\zs\~\([^ ].\{-}\)\~/
62 syntax match flexwikiCitation /\(^\|\W\)\zs??\([^ ].\{-}\)??/
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.
67 syntax match flexwikiEmoticons /\((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
69 " Aggregate all the regular text highlighting into flexwikiText
70 syntax cluster flexwikiText contains=flexwikiItalic,flexwikiBold,flexwikiCode,flexwikiDeEmphasis,flexwikiDelText,flexwikiInsText,flexwikiSuperScript,flexwikiSubScript,flexwikiCitation,flexwikiLink,flexwikiWord,flexwikiEmoticons
72 " single-line WikiPropertys
73 syntax match flexwikiSingleLineProperty /^:\?[A-Z_][_a-zA-Z0-9]\+:/
75 " TODO: multi-line WikiPropertys
78 syntax match flexwikiH1 /^!.*$/
79 syntax match flexwikiH2 /^!!.*$/
80 syntax match flexwikiH3 /^!!!.*$/
81 syntax match flexwikiH4 /^!!!!.*$/
82 syntax match flexwikiH5 /^!!!!!.*$/
83 syntax match flexwikiH6 /^!!!!!!.*$/
85 " <hr>, horizontal rule
86 syntax match flexwikiHR /^----.*$/
88 " Formatting can be turned off by ""enclosing it in pairs of double quotes""
89 syntax match flexwikiEscape /"".\{-}""/
91 " Tables. Each line starts and ends with '||'; each cell is separated by '||'
92 syntax match flexwikiTable /||/
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.
97 syntax match flexwikiList /^\(\t\| \{8}\)\s*\(\*\|1\.\).*$/ contains=@flexwikiText
99 " Treat all other lines that start with spaces as PRE-formatted text.
100 syntax match flexwikiPre /^[ \t]\+[^ \t*1].*$/
103 " Link FlexWiki syntax items to colors
104 hi def link flexwikiH1 Title
105 hi def link flexwikiH2 flexwikiH1
106 hi def link flexwikiH3 flexwikiH2
107 hi def link flexwikiH4 flexwikiH3
108 hi def link flexwikiH5 flexwikiH4
109 hi def link flexwikiH6 flexwikiH5
110 hi def link flexwikiHR flexwikiH6
112 hi def flexwikiBold term=bold cterm=bold gui=bold
113 hi def flexwikiItalic term=italic cterm=italic gui=italic
115 hi def link flexwikiCode Statement
116 hi def link flexwikiWord Underlined
118 hi def link flexwikiEscape Todo
119 hi def link flexwikiPre PreProc
120 hi def link flexwikiLink Underlined
121 hi def link flexwikiList Type
122 hi def link flexwikiTable Type
123 hi def link flexwikiEmoticons Constant
124 hi def link flexwikiDelText Comment
125 hi def link flexwikiDeEmphasis Comment
126 hi def link flexwikiInsText Constant
127 hi def link flexwikiSuperScript Constant
128 hi def link flexwikiSubScript Constant
129 hi def link flexwikiCitation Constant
131 hi def link flexwikiSingleLineProperty Identifier
133 let b:current_syntax="FlexWiki"