All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 " Maintainer: Ben Williams <benw@plasticboy.com>
4 " URL: http://plasticboy.com/markdown-vim-mode/
5 " Remark: Uses HTML syntax file
6 " TODO: Handle stuff contained within stuff (e.g. headings within blockquotes)
9 " Read the HTML syntax to start with
11 so <sfile>:p:h/html.vim
13 runtime! syntax/html.vim
15 if exists('b:current_syntax')
16 unlet b:current_syntax
22 elseif exists("b:current_syntax")
26 " don't use standard HiLink, it will not work with included syntax files
28 command! -nargs=+ HtmlHiLink hi link <args>
30 command! -nargs=+ HtmlHiLink hi def link <args>
37 "additions to HTML groups
38 syn region htmlItalic start="\\\@<!\*\S\@=" end="\S\@<=\\\@<!\*" keepend oneline
39 syn region htmlItalic start="\(^\|\s\)\@<=_\|\\\@<!_\([^_]\+\s\)\@=" end="\S\@<=[^\\]_\|[^\\]_\S\@=" keepend oneline
40 syn region htmlBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend oneline
41 syn region htmlBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend oneline
42 syn region htmlBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend oneline
43 syn region htmlBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend oneline
45 " [link](URL) | [link][id] | [link][]
46 syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]"
47 syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline
48 syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline
49 syn region mkdLink matchgroup=mkdDelimiter start="\\\@<!\[" end="\]\ze\s*[[(]" contains=@mkdNonListItem,@Spell nextgroup=mkdURL,mkdID skipwhite oneline
51 " Autolink without angle brackets.
52 " mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment
53 " ------------ _____________________ --------------------------- ________________________ ----------------- __
54 syntax match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/
56 let s:protocols = 'coap\|doi\|javascript\|aaa\|aaas\|about\|acap\|cap\|cid\|crid\|data\|dav\|dict\|dns\|file\|ftp\|geo\|go\|gopher\|h323\|http\|https\|iax\|icap\|im\|imap\|info\|ipp\|iris\|iris.beep\|iris.xpc\|iris.xpcs\|iris.lwz\|ldap\|mailto\|mid\|msrp\|msrps\|mtqp\|mupdate\|news\|nfs\|ni\|nih\|nntp\|opaquelocktoken\|pop\|pres\|rtsp\|service\|session\|shttp\|sieve\|sip\|sips\|sms\|snmp,soap.beep\|soap.beeps\|tag\|tel\|telnet\|tftp\|thismessage\|tn3270\|tip\|tv\|urn\|vemmi\|ws\|wss\|xcon\|xcon-userid\|xmlrpc.beep\|xmlrpc.beeps\|xmpp\|z39.50r\|z39.50s\|adiumxtra\|afp\|afs\|aim\|apt,attachment\|aw\|beshare\|bitcoin\|bolo\|callto\|chrome,chrome-extension\|com-eventbrite-attendee\|content\|cvs,dlna-playsingle\|dlna-playcontainer\|dtn\|dvb\|ed2k\|facetime\|feed\|finger\|fish\|gg\|git\|gizmoproject\|gtalk\|hcp\|icon\|ipn\|irc\|irc6\|ircs\|itms\|jar\|jms\|keyparc\|lastfm\|ldaps\|magnet\|maps\|market,message\|mms\|ms-help\|msnim\|mumble\|mvn\|notes\|oid\|palm\|paparazzi\|platform\|proxy\|psyc\|query\|res\|resource\|rmi\|rsync\|rtmp\|secondlife\|sftp\|sgn\|skype\|smb\|soldat\|spotify\|ssh\|steam\|svn\|teamspeak\|things\|udp\|unreal\|ut2004\|ventrilo\|view-source\|webcal\|wtai\|wyciwyg\|xfire\|xri\|ymsgr'
58 " Autolink with parenthesis.
59 execute 'syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@<!(\(\(' . s:protocols . '\):\/\/[^) ]*)\)\@=" end=")"'
61 " Autolink with angle brackets.
62 execute 'syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@<!<\(\(' . s:protocols . '\):\/\/[^> ]*>\)\@=" end=">"'
64 " Link definitions: [id]: URL (Optional Title)
65 syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite
66 syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline
67 syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained
68 syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained
69 syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained
71 "define Markdown groups
72 syn match mkdLineContinue ".$" contained
73 syn match mkdLineBreak / \+$/
74 syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell
75 syn region mkdCode start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/
76 syn region mkdCode start=/\s*``[^`]*/ end=/[^`]*``\s*/
77 syn region mkdCode start=/^\s*```\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*```\s*$/
78 syn region mkdCode start=/\s*\~\~[^\~]*/ end=/[^\~]*\~\~\s*/
79 syn region mkdCode start=/^\s*\~\~\~\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*\~\~\~\s*$/
80 syn region mkdCode start="<pre[^>]*>" end="</pre>"
81 syn region mkdCode start="<code[^>]*>" end="</code>"
82 syn region mkdFootnote start="\[^" end="\]"
83 syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
84 syn match mkdIndentCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained
85 syn match mkdListItem "^\s*[-*+]\s\+"
86 syn match mkdListItem "^\s*\d\+\.\s\+"
87 syn region mkdNonListItemBlock start="\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell
88 syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/
89 syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/
90 syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/
91 syn match mkdRule /^\s*-\{3,}$/
92 syn match mkdRule /^\s*\*\{3,5}$/
95 syn region htmlH1 start="^\s*#" end="$" contains=@Spell
96 syn region htmlH2 start="^\s*##" end="$" contains=@Spell
97 syn region htmlH3 start="^\s*###" end="$" contains=@Spell
98 syn region htmlH4 start="^\s*####" end="$" contains=@Spell
99 syn region htmlH5 start="^\s*#####" end="$" contains=@Spell
100 syn region htmlH6 start="^\s*######" end="$" contains=@Spell
101 syn match htmlH1 /^.\+\n=\+$/ contains=@Spell
102 syn match htmlH2 /^.\+\n-\+$/ contains=@Spell
105 if get(g:, 'vim_markdown_frontmatter', 0)
106 syn include @yamlTop syntax/yaml.vim
107 syn region Comment matchgroup=mkdDelimiter start="\%^---$" end="^---$" contains=@yamlTop
110 if get(g:, 'vim_markdown_math', 0)
111 syn include @tex syntax/tex.vim
112 syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$" end="\$" contains=@tex
113 syn region mkdMath matchgroup=mkdDelimiter start="\\\@<!\$\$" end="\$\$" contains=@tex
116 syn cluster mkdNonListItem contains=htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdIndentCode,mkdListItem,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
118 "highlighting for Markdown groups
119 HtmlHiLink mkdString String
120 HtmlHiLink mkdCode String
121 HtmlHiLink mkdIndentCode String
122 HtmlHiLink mkdFootnote Comment
123 HtmlHiLink mkdBlockquote Comment
124 HtmlHiLink mkdLineContinue Comment
125 HtmlHiLink mkdListItem Identifier
126 HtmlHiLink mkdRule Identifier
127 HtmlHiLink mkdLineBreak Todo
128 HtmlHiLink mkdFootnotes htmlLink
129 HtmlHiLink mkdLink htmlLink
130 HtmlHiLink mkdURL htmlString
131 HtmlHiLink mkdInlineURL htmlLink
132 HtmlHiLink mkdID Identifier
133 HtmlHiLink mkdLinkDef mkdID
134 HtmlHiLink mkdLinkDefTarget mkdURL
135 HtmlHiLink mkdLinkTitle htmlString
136 HtmlHiLink mkdDelimiter Delimiter
138 let b:current_syntax = "mkd"
140 delcommand HtmlHiLink