blob: 6b15ab2d90b80fcc031f2e68aaec64687197a93d [file] [log] [blame]
Bram Moolenaar437df8f2006-04-27 21:47:44 +00001" 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
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020017" quit when a syntax file was already loaded
18if exists("b:current_syntax")
Bram Moolenaar437df8f2006-04-27 21:47:44 +000019 finish
20endif
21
22" A WikiWord (unqualifiedWikiName)
23syntax 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]*\)\)/
24" A [bracketed wiki word]
25syntax match flexwikiWord /\[[[:alnum:]\s]\+\]/
26
27" text: "this is a link (optional tooltip)":http://www.microsoft.com
28" TODO: check URL syntax against RFC
29syntax match flexwikiLink `\("[^"(]\+\((\([^)]\+\))\)\?":\)\?\(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):\(\(\(//\)\|\(\\\\\)\)\+[A-Za-z0-9:#@%/;$~_?+-=.&\-\\\\]*\)`
30
31" text: *strong*
32syntax match flexwikiBold /\(^\|\W\)\zs\*\([^ ].\{-}\)\*/
33" '''bold'''
34syntax match flexwikiBold /'''\([^'].\{-}\)'''/
35
36" text: _emphasis_
37syntax match flexwikiItalic /\(^\|\W\)\zs_\([^ ].\{-}\)_/
38" ''italic''
39syntax match flexwikiItalic /''\([^'].\{-}\)''/
40
41" ``deemphasis``
42syntax match flexwikiDeEmphasis /``\([^`].\{-}\)``/
43
44" text: @code@
45syntax match flexwikiCode /\(^\|\s\|(\|\[\)\zs@\([^@]\+\)@/
46
47" text: -deleted text-
48syntax match flexwikiDelText /\(^\|\s\+\)\zs-\([^ <a ]\|[^ <img ]\|[^ -].*\)-/
49
50" text: +inserted text+
51syntax match flexwikiInsText /\(^\|\W\)\zs+\([^ ].\{-}\)+/
52
53" text: ^superscript^
54syntax match flexwikiSuperScript /\(^\|\W\)\zs^\([^ ].\{-}\)^/
55
56" text: ~subscript~
57syntax match flexwikiSubScript /\(^\|\W\)\zs\~\([^ ].\{-}\)\~/
58
59" text: ??citation??
60syntax match flexwikiCitation /\(^\|\W\)\zs??\([^ ].\{-}\)??/
61
62" Emoticons: must come after the Textilisms, as later rules take precedence
63" over earlier ones. This match is an approximation for the ~70 distinct
64" patterns that FlexWiki knows.
65syntax match flexwikiEmoticons /\((.)\|:[()|$@]\|:-[DOPS()\]|$@]\|;)\|:'(\)/
66
67" Aggregate all the regular text highlighting into flexwikiText
68syntax cluster flexwikiText contains=flexwikiItalic,flexwikiBold,flexwikiCode,flexwikiDeEmphasis,flexwikiDelText,flexwikiInsText,flexwikiSuperScript,flexwikiSubScript,flexwikiCitation,flexwikiLink,flexwikiWord,flexwikiEmoticons
69
70" single-line WikiPropertys
71syntax match flexwikiSingleLineProperty /^:\?[A-Z_][_a-zA-Z0-9]\+:/
72
73" TODO: multi-line WikiPropertys
74
75" Header levels, 1-6
76syntax match flexwikiH1 /^!.*$/
77syntax match flexwikiH2 /^!!.*$/
78syntax match flexwikiH3 /^!!!.*$/
79syntax match flexwikiH4 /^!!!!.*$/
80syntax match flexwikiH5 /^!!!!!.*$/
81syntax match flexwikiH6 /^!!!!!!.*$/
82
83" <hr>, horizontal rule
84syntax match flexwikiHR /^----.*$/
85
86" Formatting can be turned off by ""enclosing it in pairs of double quotes""
87syntax match flexwikiEscape /"".\{-}""/
88
89" Tables. Each line starts and ends with '||'; each cell is separated by '||'
90syntax match flexwikiTable /||/
91
92" Bulleted list items start with one or tabs, followed by whitespace, then '*'
93" Numeric list items start with one or tabs, followed by whitespace, then '1.'
94" Eight spaces at the beginning of the line is equivalent to the leading tab.
95syntax match flexwikiList /^\(\t\| \{8}\)\s*\(\*\|1\.\).*$/ contains=@flexwikiText
96
97" Treat all other lines that start with spaces as PRE-formatted text.
98syntax match flexwikiPre /^[ \t]\+[^ \t*1].*$/
99
100
101" Link FlexWiki syntax items to colors
102hi def link flexwikiH1 Title
103hi def link flexwikiH2 flexwikiH1
104hi def link flexwikiH3 flexwikiH2
105hi def link flexwikiH4 flexwikiH3
106hi def link flexwikiH5 flexwikiH4
107hi def link flexwikiH6 flexwikiH5
108hi def link flexwikiHR flexwikiH6
109
110hi def flexwikiBold term=bold cterm=bold gui=bold
111hi def flexwikiItalic term=italic cterm=italic gui=italic
112
113hi def link flexwikiCode Statement
114hi def link flexwikiWord Underlined
115
116hi def link flexwikiEscape Todo
117hi def link flexwikiPre PreProc
118hi def link flexwikiLink Underlined
119hi def link flexwikiList Type
120hi def link flexwikiTable Type
121hi def link flexwikiEmoticons Constant
122hi def link flexwikiDelText Comment
123hi def link flexwikiDeEmphasis Comment
124hi def link flexwikiInsText Constant
125hi def link flexwikiSuperScript Constant
126hi def link flexwikiSubScript Constant
127hi def link flexwikiCitation Constant
128
129hi def link flexwikiSingleLineProperty Identifier
130
131let b:current_syntax="FlexWiki"
132
133" vim:tw=0: