" Other Home: http://www.vim.org/scripts/script.php?script_id=1529
" Author: George V. Reilly
" Filenames: *.wiki
" Last Change: Wed Apr 26 11:00 PM 2006 P
" Version: 0.3
" Note: The horrible regexps were reverse-engineered from
" FlexWikiCore\EngineSource\Formatter.cs, with help from the Regex Analyzer
" in The Regulator, http://regulator.sourceforge.net/ .NET uses Perl-style
" regexes, which use a different syntax than Vim (fewer \s).
" The primary test case is FlexWiki\FormattingRules.wiki
" Quit if syntax file is already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" A WikiWord (unqualifiedWikiName)
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]*\)\)/
" A [bracketed wiki word]
syntax match flexwikiWord /\[[[:alnum:]\s]\+\]/
" text: "this is a link (optional tooltip)":http://www.microsoft.com
" TODO: check URL syntax against RFC
syntax match flexwikiLink `\("[^"(]\+\((\([^)]\+\))\)\?":\)\?\(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\(\(\(//\)\|\(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+-=.&\-\\\\]*\)`
" text: *strong*
syntax match flexwikiBold /\(^\|\W\)\zs\*\([^ ].\{-}\)\*/
" '''bold'''
syntax match flexwikiBold /'''\([^'].\{-}\)'''/
" text: _emphasis_
syntax match flexwikiItalic /\(^\|\W\)\zs_\([^ ].\{-}\)_/
" ''italic''
syntax match flexwikiItalic /''\([^'].\{-}\)''/
" ``deemphasis``
syntax match flexwikiDeEmphasis /``\([^`].\{-}\)``/
" text: @code@
syntax match flexwikiCode /\(^\|\s\|(\|\[\)\zs@\([^@]\+\)@/
" text: -deleted text-
syntax match flexwikiDelText /\(^\|\s\+\)\zs-\([^ <a ]\|[^ <img ]\|[^ -].*\)-/
" text: +inserted text+
syntax match flexwikiInsText /\(^\|\W\)\zs+\([^ ].\{-}\)+/
" text: ^superscript^
syntax match flexwikiSuperScript /\(^\|\W\)\zs^\([^ ].\{-}\)^/
" text: ~subscript~
syntax match flexwikiSubScript /\(^\|\W\)\zs\~\([^ ].\{-}\)\~/
" text: ??citation??
syntax match flexwikiCitation /\(^\|\W\)\zs??\([^ ].\{-}\)??/
" Emoticons: must come after the Textilisms, as later rules take precedence
" over earlier ones. This match is an approximation for the ~70 distinct
" patterns that FlexWiki knows.
syntax match flexwikiEmoticons /\((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
" Aggregate all the regular text highlighting into flexwikiText