2202
|
1 " Vim syntax file
|
|
2 " Language: Markdown
|
|
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
|
4 " Filenames: *.markdown
|
|
5 " Last Change: 2010 May 21
|
|
6
|
|
7 if exists("b:current_syntax")
|
|
8 finish
|
|
9 endif
|
|
10
|
|
11 runtime! syntax/html.vim
|
|
12 unlet! b:current_syntax
|
|
13
|
|
14 syn sync minlines=10
|
|
15 syn case ignore
|
|
16
|
|
17 syn match markdownValid '[<>]\S\@!'
|
|
18 syn match markdownValid '&\%(#\=\w*;\)\@!'
|
|
19
|
|
20 syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock
|
|
21
|
|
22 syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule
|
|
23 syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop
|
|
24
|
|
25 syn match markdownH1 ".\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule
|
|
26 syn match markdownH2 ".\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule
|
|
27
|
|
28 syn match markdownHeadingRule "^[=-]\+$" contained
|
|
29
|
|
30 syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
|
31 syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
|
32 syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
|
33 syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
|
34 syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
|
35 syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
|
|
36
|
|
37 syn match markdownBlockquote ">\s" contained nextgroup=@markdownBlock
|
|
38
|
|
39 syn region markdownCodeBlock start=" \|\t" end="$" contained
|
|
40
|
|
41 " TODO: real nesting
|
|
42 syn match markdownListMarker " \{0,4\}[-*+]\%(\s\+\S\)\@=" contained
|
|
43 syn match markdownOrderedListMarker " \{0,4}\<\d\+\.\%(\s*\S\)\@=" contained
|
|
44
|
|
45 syn match markdownRule "\* *\* *\*[ *]*$" contained
|
|
46 syn match markdownRule "- *- *-[ -]*$" contained
|
|
47
|
|
48 syn match markdownLineBreak "\s\{2,\}$"
|
|
49
|
|
50 syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
|
|
51 syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
|
|
52 syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
|
|
53 syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
|
|
54 syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained
|
|
55 syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained
|
|
56
|
|
57 syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" keepend nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
|
|
58 syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
|
|
59 syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
|
|
60 syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
|
|
61
|
|
62 syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
|
|
63 syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
|
|
64 syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart
|
|
65 syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart
|
|
66 syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart
|
|
67 syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart
|
|
68 syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" transparent keepend contains=markdownLineStart
|
|
69 syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart
|
|
70
|
|
71 syn match markdownEscape "\\[][\\`*_{}()#+.!-]"
|
|
72
|
|
73 hi def link markdownH1 htmlH1
|
|
74 hi def link markdownH2 htmlH2
|
|
75 hi def link markdownH3 htmlH3
|
|
76 hi def link markdownH4 htmlH4
|
|
77 hi def link markdownH5 htmlH5
|
|
78 hi def link markdownH6 htmlH6
|
|
79 hi def link markdownHeadingRule markdownRule
|
|
80 hi def link markdownHeadingDelimiter Delimiter
|
|
81 hi def link markdownOrderedListMarker markdownListMarker
|
|
82 hi def link markdownListMarker htmlTagName
|
|
83 hi def link markdownBlockquote Comment
|
|
84 hi def link markdownRule PreProc
|
|
85
|
|
86 hi def link markdownLinkText htmlLink
|
|
87 hi def link markdownIdDeclaration Typedef
|
|
88 hi def link markdownId Type
|
|
89 hi def link markdownAutomaticLink markdownUrl
|
|
90 hi def link markdownUrl Float
|
|
91 hi def link markdownUrlTitle String
|
|
92 hi def link markdownIdDelimiter markdownLinkDelimiter
|
|
93 hi def link markdownUrlDelimiter htmlTag
|
|
94 hi def link markdownUrlTitleDelimiter Delimiter
|
|
95
|
|
96 hi def link markdownItalic htmlItalic
|
|
97 hi def link markdownBold htmlBold
|
|
98 hi def link markdownBoldItalic htmlBoldItalic
|
|
99 hi def link markdownCodeDelimiter Delimiter
|
|
100
|
|
101 hi def link markdownEscape Special
|
|
102
|
|
103 let b:current_syntax = "markdown"
|
|
104
|
|
105 " vim:set sw=2:
|