Mercurial > vim
annotate runtime/syntax/markdown.vim @ 10555:fff45421182b v8.0.0167
patch 8.0.0167: str2nr()/str2float() fail with negative values
commit https://github.com/vim/vim/commit/08243d26d22ad44a857d02c90071578577b8a55d
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 10 16:12:29 2017 +0100
patch 8.0.0167: str2nr()/str2float() fail with negative values
Problem: str2nr() and str2float() do not always work with negative values.
Solution: Be more flexible about handling signs. (LemonBoy, closes https://github.com/vim/vim/issues/1332)
Add more tests.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 10 Jan 2017 16:15:04 +0100 |
parents | 43efa4f5a8ea |
children | 5c40013d45ee |
rev | line source |
---|---|
2202 | 1 " Vim syntax file |
2 " Language: Markdown | |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | |
4 " Filenames: *.markdown | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
5 " Last Change: 2016 Aug 29 |
2202 | 6 |
7 if exists("b:current_syntax") | |
8 finish | |
9 endif | |
10 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
11 if !exists('main_syntax') |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
12 let main_syntax = 'markdown' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
13 endif |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
14 |
2202 | 15 runtime! syntax/html.vim |
16 unlet! b:current_syntax | |
17 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
18 if !exists('g:markdown_fenced_languages') |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
19 let g:markdown_fenced_languages = [] |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
20 endif |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
21 for s:type in map(copy(g:markdown_fenced_languages),'matchstr(v:val,"[^=]*$")') |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
22 if s:type =~ '\.' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
23 let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*') |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
24 endif |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
25 exe 'syn include @markdownHighlight'.substitute(s:type,'\.','','g').' syntax/'.matchstr(s:type,'[^.]*').'.vim' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
26 unlet! b:current_syntax |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
27 endfor |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
28 unlet! s:type |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
29 |
2202 | 30 syn sync minlines=10 |
31 syn case ignore | |
32 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
33 syn match markdownValid '[<>]\c[a-z/$!]\@!' |
2202 | 34 syn match markdownValid '&\%(#\=\w*;\)\@!' |
35 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
36 syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock,htmlSpecialChar |
2202 | 37 |
38 syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
39 syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop,markdownError |
2202 | 40 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
41 syn match markdownH1 "^.\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
42 syn match markdownH2 "^.\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule,markdownAutomaticLink |
2202 | 43 |
44 syn match markdownHeadingRule "^[=-]\+$" contained | |
45 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
46 syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
47 syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
48 syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
49 syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
50 syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
51 syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained |
2202 | 52 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
53 syn match markdownBlockquote ">\%(\s\|$\)" contained nextgroup=@markdownBlock |
2202 | 54 |
55 syn region markdownCodeBlock start=" \|\t" end="$" contained | |
56 | |
57 " TODO: real nesting | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
58 syn match markdownListMarker "\%(\t\| \{0,4\}\)[-*+]\%(\s\+\S\)\@=" contained |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
59 syn match markdownOrderedListMarker "\%(\t\| \{0,4}\)\<\d\+\.\%(\s\+\S\)\@=" contained |
2202 | 60 |
61 syn match markdownRule "\* *\* *\*[ *]*$" contained | |
62 syn match markdownRule "- *- *-[ -]*$" contained | |
63 | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
64 syn match markdownLineBreak " \{2,\}$" |
2202 | 65 |
66 syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite | |
67 syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained | |
68 syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained | |
69 syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained | |
70 syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained | |
71 syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained | |
72 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
73 syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart |
2202 | 74 syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained |
75 syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained | |
76 syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline | |
77 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
78 let s:concealends = has('conceal') ? ' concealends' : '' |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
79 exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart' . s:concealends |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
80 exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart' . s:concealends |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
81 exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic' . s:concealends |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
82 exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic' . s:concealends |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
83 exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart' . s:concealends |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
84 exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart' . s:concealends |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
85 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
86 syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart |
2202 | 87 syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
88 syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*```.*$" end="^\s*```\ze\s*$" keepend |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
89 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
90 syn match markdownFootnote "\[^[^\]]\+\]" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
91 syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:" |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
92 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
93 if main_syntax ==# 'markdown' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
94 for s:type in g:markdown_fenced_languages |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
95 exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*```\s*'.matchstr(s:type,'[^=]*').'\>.*$" end="^\s*```\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g') |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
96 endfor |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
97 unlet! s:type |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
98 endif |
2202 | 99 |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
100 syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]" |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
101 syn match markdownError "\w\@<=_\w\@=" |
2202 | 102 |
103 hi def link markdownH1 htmlH1 | |
104 hi def link markdownH2 htmlH2 | |
105 hi def link markdownH3 htmlH3 | |
106 hi def link markdownH4 htmlH4 | |
107 hi def link markdownH5 htmlH5 | |
108 hi def link markdownH6 htmlH6 | |
109 hi def link markdownHeadingRule markdownRule | |
110 hi def link markdownHeadingDelimiter Delimiter | |
111 hi def link markdownOrderedListMarker markdownListMarker | |
112 hi def link markdownListMarker htmlTagName | |
113 hi def link markdownBlockquote Comment | |
114 hi def link markdownRule PreProc | |
115 | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
116 hi def link markdownFootnote Typedef |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
117 hi def link markdownFootnoteDefinition Typedef |
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
118 |
2202 | 119 hi def link markdownLinkText htmlLink |
120 hi def link markdownIdDeclaration Typedef | |
121 hi def link markdownId Type | |
122 hi def link markdownAutomaticLink markdownUrl | |
123 hi def link markdownUrl Float | |
124 hi def link markdownUrlTitle String | |
125 hi def link markdownIdDelimiter markdownLinkDelimiter | |
126 hi def link markdownUrlDelimiter htmlTag | |
127 hi def link markdownUrlTitleDelimiter Delimiter | |
128 | |
129 hi def link markdownItalic htmlItalic | |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
130 hi def link markdownItalicDelimiter markdownItalic |
2202 | 131 hi def link markdownBold htmlBold |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
132 hi def link markdownBoldDelimiter markdownBold |
2202 | 133 hi def link markdownBoldItalic htmlBoldItalic |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
134 hi def link markdownBoldItalicDelimiter markdownBoldItalic |
2202 | 135 hi def link markdownCodeDelimiter Delimiter |
136 | |
137 hi def link markdownEscape Special | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
138 hi def link markdownError Error |
2202 | 139 |
140 let b:current_syntax = "markdown" | |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
141 if main_syntax ==# 'markdown' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
142 unlet main_syntax |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
143 endif |
2202 | 144 |
145 " vim:set sw=2: |