Created
November 17, 2013 21:14
-
-
Save rcmdnk/7518342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mod:syntax/markdown.vim b/master:syntax/mkd.vim | |
index a9e91bb..575466b 100644 | |
--- a/mod:syntax/markdown.vim | |
+++ b/master:syntax/mkd.vim | |
@@ -36,27 +36,24 @@ syn case ignore | |
syn sync linebreaks=1 | |
"additions to HTML groups | |
-syn region htmlItalic start="\\\@<!\*\S\@=" end="\S\@<=\\\@<!\*" keepend oneline contains=@Spell | |
-syn region htmlItalic start="\(^\|\s\)\@<=_\|\\\@<!_\([^_]\+\s\)\@=" end="\S\@<=_\|_\S\@=" keepend oneline contains=@Spell | |
-syn region htmlBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend oneline contains=@Spell | |
-syn region htmlBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend oneline contains=@Spell | |
-syn region htmlBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend oneline contains=@Spell | |
-syn region htmlBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend oneline contains=@Spell | |
+syn region htmlItalic start="\\\@<!\*\S\@=" end="\S\@<=\\\@<!\*" keepend oneline | |
+syn region htmlItalic start="\(^\|\s\)\@<=_\|\\\@<!_\([^_]\+\s\)\@=" end="\S\@<=_\|_\S\@=" keepend oneline | |
+syn region htmlBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend oneline | |
+syn region htmlBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend oneline | |
+syn region htmlBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend oneline | |
+syn region htmlBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend oneline | |
" [link](URL) | [link][id] | [link][] | |
syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]" | |
syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline | |
-syn region mkdURL matchgroup=mkdDelimiter start="\(\]\)\@<=(" end=")" contained oneline | |
+syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline | |
syn region mkdLink matchgroup=mkdDelimiter start="\\\@<!\[" end="\]\ze\s*[[(]" contains=@Spell nextgroup=mkdURL,mkdID skipwhite oneline | |
- | |
-" Inline url (http(s)://, ftp://, //) | |
-syn region mkdInlineURL matchgroup=mkdInlineURL start="\(https\?:\|ftp:\|^\|[^:]\@<=\)\/\/" end="\()\|}\|]\|,\|\"\|\'\| \|$\|\. \|\.$\)\@=" | |
-syn region mkdInlineURL matchgroup=mkdDelimiter start="<\(\(https\?:\|ftp:\|^\|[^:]\@<=\)\/\/\)\@=" end=">" | |
-" Inline mail (user@mail.com) | |
-syn region mkdInlineURL matchgroup=Normal start="\(^\| \|(\|=\)\([-.[:alnum:]_~+]\+@\)\@=" end="\()\|}\|]\|,\|\"\|\'\| \|$\|\. \|\.$\)\@=" | |
-syn region mkdInlineURL matchgroup=mkdDelimiter start="<\([-.[:alnum:]_~+]\+@\)\@=" end=">" | |
+" mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment | |
+" ------------ _____________________ --------------------------- ________________________ ----------------- __ | |
+syntax match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/ | |
" Link definitions: [id]: URL (Optional Title) | |
+" TODO handle automatic links without colliding with htmlTag (<URL>) | |
syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite | |
syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline | |
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained | |
@@ -67,16 +64,17 @@ syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained | |
syn match mkdLineContinue ".$" contained | |
syn match mkdLineBreak / \+$/ | |
syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell | |
-syn region mkdCode matchgroup=mkdDelimiter start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/ | |
-syn region mkdCode matchgroup=mkdDelimiter start=/\s*``[^`]*/ end=/[^`]*``\s*/ | |
-syn region mkdCode matchgroup=mkdDelimiter start=/^```.*$/ end=/^```\s*$/ | |
-syn region mkdCode matchgroup=mkdDelimiter start=/^[~]\{3,}.*$/ end=/^[~]\{3,}$/ | |
-syn region mkdCode matchgroup=mkdDelimiter start="<pre[^>]*>" end="</pre>" | |
-syn region mkdCode matchgroup=mkdDelimiter start="<code[^>]*>" end="</code>" | |
+syn region mkdCode start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/ | |
+syn region mkdCode start=/\s*``[^`]*/ end=/[^`]*``\s*/ | |
+syn region mkdCode start=/^```\s*\w*\s*$/ end=/^```\s*$/ | |
+syn region mkdCode start="<pre[^>]*>" end="</pre>" | |
+syn region mkdCode start="<code[^>]*>" end="</code>" | |
syn region mkdFootnote start="\[^" end="\]" | |
-syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ | |
+syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/ | |
+syn match mkdIndentCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained | |
syn match mkdListItem "^\s*[-*+]\s\+" | |
syn match mkdListItem "^\s*\d\+\.\s\+" | |
+syn region mkdNonListItemBlock start="\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem | |
syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/ | |
syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/ | |
syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/ | |
@@ -93,10 +91,7 @@ syn region htmlH6 start="^\s*######" end="\($\|#\+\)" contain | |
syn match htmlH1 /^.\+\n=\+$/ contains=@Spell | |
syn match htmlH2 /^.\+\n-\+$/ contains=@Spell | |
-" Liquid Tag | |
-syn region liquidTag matchgroup=mkdDelimiter start="{%" end="%}" oneline | |
-syn region mkdCode matchgroup=liquidTag start=/^{%\s*codeblock.*%}$/ end=/^{%\s*endcodeblock.*%}$/ | |
-syn region liquidComment start=/^{%\s*comment.*%}$/ end=/^{%\s*endcomment.*%}$/ | |
+syn cluster mkdNonListItem contains=htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdID,mkdURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdIndentCode,mkdListItem,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6 | |
"highlighting for Markdown groups | |
HtmlHiLink mkdString String | |
@@ -117,9 +112,6 @@ HtmlHiLink mkdLinkDef mkdID | |
HtmlHiLink mkdLinkDefTarget mkdURL | |
HtmlHiLink mkdLinkTitle htmlString | |
-HtmlHiLink liquidTag MoreMsg | |
-HtmlHiLink liquidComment NonText | |
- | |
HtmlHiLink mkdDelimiter Delimiter | |
" Automatically insert bullets | |
@@ -127,7 +119,7 @@ setlocal formatoptions+=r | |
" Accept various markers as bullets | |
setlocal comments=b:*,b:+,b:- | |
-let b:current_syntax = "markdown" | |
+let b:current_syntax = "mkd" | |
delcommand HtmlHiLink | |
" vim: ts=8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment