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.
2 unlet! b:mkd_known_filetypes
3 unlet! b:mkd_included_filetypes
9 AssertNotEqual SyntaxOf('a'), 'htmlBold'
10 AssertEqual SyntaxOf('b'), 'htmlBold'
11 AssertNotEqual SyntaxOf('c'), 'htmlBold'
17 AssertNotEqual SyntaxOf('a'), 'htmlBold'
18 AssertEqual SyntaxOf('b'), 'htmlBold'
19 AssertNotEqual SyntaxOf('c'), 'htmlBold'
25 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
26 AssertEqual SyntaxOf('b'), 'htmlItalic'
27 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
33 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
34 AssertEqual SyntaxOf('b'), 'htmlItalic'
35 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
40 Execute (italic text has underscores):
41 AssertEqual SyntaxOf('a'), 'htmlItalic'
42 AssertEqual SyntaxOf('b'), 'htmlItalic'
47 Execute (not italic with escaped asterisks):
48 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
49 AssertNotEqual SyntaxOf('b'), 'htmlItalic'
50 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
55 Execute (not italic with escaped underscores):
56 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
57 AssertNotEqual SyntaxOf('b'), 'htmlItalic'
58 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
63 Execute (italic with escaped underscores):
64 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
65 AssertEqual SyntaxOf('b'), 'htmlItalic'
66 AssertEqual SyntaxOf('c'), 'htmlItalic'
67 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
72 Execute (not italic underscores within text):
73 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
74 AssertNotEqual SyntaxOf('b'), 'htmlItalic'
75 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
80 Execute (italic with escaped asterisks):
81 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
82 AssertEqual SyntaxOf('b'), 'htmlItalic'
83 AssertEqual SyntaxOf('c'), 'htmlItalic'
84 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
89 Execute (bold with escaped underscores):
90 AssertNotEqual SyntaxOf('a'), 'htmlBold'
91 AssertEqual SyntaxOf('b'), 'htmlBold'
92 AssertEqual SyntaxOf('c'), 'htmlBold'
93 AssertNotEqual SyntaxOf('d'), 'htmlBold'
99 Execute (italic with underscores in multiple lines):
100 AssertEqual SyntaxOf('a'), 'htmlItalic'
101 AssertEqual SyntaxOf('b'), 'htmlItalic'
102 AssertEqual SyntaxOf('c'), 'htmlItalic'
103 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
109 Execute (bold with underscores in multiple lines):
110 AssertEqual SyntaxOf('a'), 'htmlBold'
111 AssertEqual SyntaxOf('b'), 'htmlBold'
112 AssertEqual SyntaxOf('c'), 'htmlBold'
113 AssertNotEqual SyntaxOf('d'), 'htmlBold'
119 Execute (bold italic with underscores in multiple lines):
120 AssertEqual SyntaxOf('a'), 'htmlBoldItalic'
121 AssertEqual SyntaxOf('b'), 'htmlBoldItalic'
122 AssertEqual SyntaxOf('c'), 'htmlBoldItalic'
123 AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
129 Execute (italic with asterisks in multiple lines):
130 AssertEqual SyntaxOf('a'), 'htmlItalic'
131 AssertEqual SyntaxOf('b'), 'htmlItalic'
132 AssertEqual SyntaxOf('c'), 'htmlItalic'
133 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
139 Execute (bold with asterisks in multiple lines):
140 AssertEqual SyntaxOf('a'), 'htmlBold'
141 AssertEqual SyntaxOf('b'), 'htmlBold'
142 AssertEqual SyntaxOf('c'), 'htmlBold'
143 AssertNotEqual SyntaxOf('d'), 'htmlBold'
149 Execute (bold italic with asterisks in multiple lines):
150 AssertEqual SyntaxOf('a'), 'htmlBoldItalic'
151 AssertEqual SyntaxOf('b'), 'htmlBoldItalic'
152 AssertEqual SyntaxOf('c'), 'htmlBoldItalic'
153 AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
158 Execute (not italic with an asterisk):
159 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
164 Execute (not bold with double underscores):
165 AssertNotEqual SyntaxOf('_'), 'htmlBold'
166 AssertNotEqual SyntaxOf('a'), 'htmlBold'
167 AssertNotEqual SyntaxOf('b'), 'htmlBold'
174 Execute (link with title):
175 AssertEqual SyntaxOf('a'), 'mkdLink'
176 AssertEqual SyntaxOf('b'), 'mkdURL'
182 Execute (link text with newline):
183 AssertEqual SyntaxOf('a'), 'mkdLink'
184 AssertEqual SyntaxOf('b'), 'mkdLink'
185 AssertEqual SyntaxOf('c'), 'mkdURL'
192 Execute (parenthesis not in link):
193 AssertNotEqual SyntaxOf('a'), 'mkdURL'
194 AssertNotEqual SyntaxOf('b'), 'mkdURL'
199 Execute (multiple links on a line):
200 AssertNotEqual SyntaxOf('c'), 'mkdLink'
201 AssertNotEqual SyntaxOf('c'), 'mkdURL'
206 Execute (space is not allowed between link text and parenthesis):
207 AssertNotEqual SyntaxOf('a'), 'mkdLink'
208 AssertNotEqual SyntaxOf('b'), 'mkdURL'
213 Execute (conceal link):
215 setlocal conceallevel=2
216 AssertEqual synconcealed(1, 1)[0], 1
217 AssertEqual synconcealed(1, 2)[0], 0
218 AssertEqual synconcealed(1, 3)[0], 1
219 AssertEqual synconcealed(1, 4)[0], 1
220 AssertEqual synconcealed(1, 4)[0], 1
221 AssertEqual synconcealed(1, 5)[0], 1
222 AssertEqual synconcealed(1, 6)[0], 1
223 setlocal conceallevel=0
226 Execute (disable conceal):
228 let g:vim_markdown_conceal=0
230 setlocal conceallevel=2
231 AssertEqual synconcealed(1, 1)[0], 0
232 AssertEqual synconcealed(1, 2)[0], 0
233 AssertEqual synconcealed(1, 3)[0], 0
234 AssertEqual synconcealed(1, 4)[0], 0
235 AssertEqual synconcealed(1, 4)[0], 0
236 AssertEqual synconcealed(1, 5)[0], 0
237 AssertEqual synconcealed(1, 6)[0], 0
239 let g:vim_markdown_conceal=1
241 AssertEqual synconcealed(1, 1)[0], 1
242 AssertEqual synconcealed(1, 2)[0], 0
243 AssertEqual synconcealed(1, 3)[0], 1
244 AssertEqual synconcealed(1, 4)[0], 1
245 AssertEqual synconcealed(1, 4)[0], 1
246 AssertEqual synconcealed(1, 5)[0], 1
247 AssertEqual synconcealed(1, 6)[0], 1
249 setlocal conceallevel=0
250 unlet g:vim_markdown_conceal
260 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
261 AssertEqual SyntaxOf('<'), 'mkdDelimiter'
262 AssertEqual SyntaxOf('b'), 'mkdInlineURL'
263 AssertEqual SyntaxOf('>'), 'mkdDelimiter'
264 AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
269 Execute (autolink with domain starting with a number):
270 AssertEqual SyntaxOf('12monkeys'), 'mkdInlineURL'
275 Execute (autolink with scheme case is insensitive):
276 AssertEqual SyntaxOf('a'), 'mkdInlineURL'
281 Execute (autolink without scheme is not a link):
282 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
290 Execute (autolink with space is not a link):
291 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
292 AssertNotEqual SyntaxOf('b'), 'mkdInlineURL'
293 AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
294 AssertNotEqual SyntaxOf('d'), 'mkdInlineURL'
295 AssertNotEqual SyntaxOf('e'), 'mkdInlineURL'
300 Execute (autolinks can be backslash escaped):
301 AssertNotEqual SyntaxOf('<'), 'mkdDelimiter'
306 Execute (autolink in parenthesis):
307 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
308 AssertEqual SyntaxOf('('), 'mkdDelimiter'
309 AssertEqual SyntaxOf('b'), 'mkdInlineURL'
310 AssertEqual SyntaxOf(')'), 'mkdDelimiter'
311 AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
314 [![a](http://b)](http://c)
316 Execute (autolink in link text):
317 AssertEqual SyntaxOf('!'), 'mkdDelimiter'
318 AssertEqual SyntaxOf('a'), 'mkdLink'
319 AssertEqual SyntaxOf('b'), 'mkdURL'
320 AssertEqual SyntaxOf('c'), 'mkdURL'
329 Execute (code blocks can be fenced with tildes):
330 AssertEqual SyntaxOf('c'), 'mkdCode'
337 Execute (code blocks can be fenced with tildes longer than 3):
338 AssertEqual SyntaxOf('c'), 'mkdCode'
345 Execute (code blocks can be fenced with backticks longer than 3):
346 AssertEqual SyntaxOf('c'), 'mkdCode'
353 Execute (code blocks can have a language specifier):
354 AssertEqual SyntaxOf('c'), 'mkdCode'
363 Execute (code blocks can be fenced with backticks and a language specifier):
364 AssertEqual SyntaxOf('code'), 'mkdCode'
365 AssertNotEqual SyntaxOf('text'), 'mkdCode'
375 Execute (indent code blocks):
376 AssertNotEqual SyntaxOf('a'), 'mkdCode'
377 AssertEqual SyntaxOf('b'), 'mkdCode'
378 AssertEqual SyntaxOf('c'), 'mkdCode'
387 Execute (indent code blocks after header):
388 AssertNotEqual SyntaxOf('a'), 'mkdCode'
389 AssertNotEqual SyntaxOf('b'), 'mkdCode'
390 AssertEqual SyntaxOf('c'), 'mkdCode'
399 Execute (indent code blocks after list):
400 AssertNotEqual SyntaxOf('a'), 'mkdCode'
401 AssertNotEqual SyntaxOf('b'), 'mkdCode'
402 AssertEqual SyntaxOf('c'), 'mkdCode'
408 Execute (indent code block at beginning of file):
409 AssertEqual SyntaxOf('a'), 'mkdCode'
410 AssertEqual SyntaxOf('b'), 'mkdCode'
423 Execute (fenced code block syntax with a language specifier):
424 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
426 AssertEqual SyntaxOf('include'), 'cInclude'
427 AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
428 AssertEqual SyntaxOf('def'), 'rubyDefine'
451 Execute (fenced code block syntax with a language specifier after whitespace):
452 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
454 AssertEqual SyntaxOf('include'), 'cInclude'
455 AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
456 AssertEqual SyntaxOf('g:a'), 'vimVar'
457 AssertEqual SyntaxOf('def'), 'rubyDefine'
458 AssertNotEqual SyntaxOf('class'), 'rubyClass'
469 Execute (fenced code block syntax with alias language specifier):
470 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
472 AssertEqual SyntaxOf('g:a'), 'vimVar'
473 AssertEqual SyntaxOf('g:b'), 'vimVar'
480 Execute (fenced code block languages setting):
481 let g:vim_markdown_fenced_languages = ['csharp=cs']
482 source ../ftplugin/markdown.vim
483 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
485 AssertEqual SyntaxOf('foo'), 'csString'
486 unlet g:vim_markdown_fenced_languages
493 Execute (fenced code block includes language syntax with reopening same buffer):
494 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
499 set filetype=markdown
500 execute "normal! i```vim\<cr>let g:a = 1\<cr>```"
502 AssertEqual SyntaxOf('g:a'), 'vimVar'
509 Execute (fenced code block syntax with an unknown language specifier):
510 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
512 AssertEqual SyntaxOf('code'), 'mkdSnippetA_B_'
521 Execute (first = or - in fenced code block is not setex headers):
522 AssertEqual SyntaxOf('='), 'mkdCode'
523 AssertEqual SyntaxOf('-'), 'mkdCode'
530 Execute (fenced code block with extended info strings):
531 AssertEqual SyntaxOf('a'), 'mkdCode'
533 # Code Blocks in pre and code tag
540 Execute (code block in pre tag):
541 AssertEqual SyntaxOf('a'), 'mkdCode'
548 Execute (code block in code tag):
549 AssertEqual SyntaxOf('a'), 'mkdCode'
556 Execute (not code block in escaped pre tag):
557 AssertNotEqual SyntaxOf('a'), 'mkdCode'
564 Execute (not code block in escaped code tag):
565 AssertNotEqual SyntaxOf('a'), 'mkdCode'
576 AssertNotEqual SyntaxOf('x'), 'mkdMath'
577 AssertNotEqual SyntaxOf('y'), 'mkdMath'
578 let g:vim_markdown_math=1
580 AssertNotEqual SyntaxOf('a'), 'mkdMath'
581 AssertNotEqual SyntaxOf('b'), 'mkdMath'
582 AssertNotEqual SyntaxOf('c'), 'mkdMath'
583 AssertNotEqual SyntaxOf('d'), 'mkdMath'
584 AssertNotEqual SyntaxOf('e'), 'mkdMath'
585 AssertNotEqual SyntaxOf('f'), 'mkdMath'
586 AssertEqual SyntaxOf('x'), 'mkdMath'
587 AssertEqual SyntaxOf('y'), 'mkdMath'
588 let g:vim_markdown_math=0
590 AssertNotEqual SyntaxOf('x'), 'mkdMath'
591 AssertNotEqual SyntaxOf('y'), 'mkdMath'
602 Execute (multiline math):
603 let g:vim_markdown_math=1
605 AssertNotEqual SyntaxOf('a'), 'mkdMath'
606 AssertEqual SyntaxOf('b'), 'mkdMath'
607 AssertNotEqual SyntaxOf('c'), 'mkdMath'
613 Execute (math tex highlighting):
614 let g:vim_markdown_math=0
616 AssertNotEqual SyntaxOf('sqrt'), 'texStatement'
617 AssertNotEqual SyntaxOf('frac'), 'texStatement'
618 let g:vim_markdown_math=1
620 AssertEqual SyntaxOf('sqrt'), 'texStatement'
621 AssertEqual SyntaxOf('frac'), 'texStatement'
630 Execute (YAML frontmatter is controlled by the option):
631 AssertNotEqual SyntaxOf('a')[0:3], 'yaml'
632 let g:vim_markdown_frontmatter=1
634 AssertEqual SyntaxOf('a')[0:3], 'yaml'
635 let g:vim_markdown_frontmatter=0
637 AssertNotEqual SyntaxOf('a')[0:3], 'yaml'
645 Execute (YAML frontmatter only works if it's the first thing in the file):
646 let g:vim_markdown_frontmatter=1
648 AssertNotEqual SyntaxOf('a')[0:3], 'yaml'
657 Execute (rules are not mistaken by YAML frontmatter delimiters):
658 let g:vim_markdown_frontmatter=1
660 AssertEqual SyntaxAt(5, 1), 'mkdRule'
661 unlet g:vim_markdown_frontmatter
670 Execute (TOML frontmatter is controlled by the option):
672 AssertNotEqual SyntaxOf('b'), 'tomlString'
673 let g:vim_markdown_toml_frontmatter=1
675 AssertEqual SyntaxOf('b'), 'tomlString'
676 let g:vim_markdown_toml_frontmatter=0
678 AssertNotEqual SyntaxOf('b'), 'tomlString'
686 Execute (TOML frontmatter only works if it's the first thing in the file):
687 let g:vim_markdown_toml_frontmatter=1
689 AssertNotEqual SyntaxOf('b'), 'tomlString'
690 unlet g:vim_markdown_toml_frontmatter
699 Execute (JSON frontmatter is controlled by the option):
701 AssertNotEqual SyntaxOf('a'), 'jsonKeyword'
702 let g:vim_markdown_json_frontmatter=1
704 AssertEqual SyntaxOf('a'), 'jsonKeyword'
705 let g:vim_markdown_json_frontmatter=0
707 AssertNotEqual SyntaxOf('a'), 'jsonKeyword'
715 Execute (JSON frontmatter only works if it's the first thing in the file):
716 let g:vim_markdown_json_frontmatter=1
718 AssertNotEqual SyntaxOf('a'), 'jsonKeyword'
719 unlet g:vim_markdown_json_frontmatter
730 Execute (header title starts with #):
731 AssertEqual SyntaxOf('a'), 'htmlH1'
732 AssertEqual SyntaxOf('b'), 'htmlH2'
747 ## h2 trailing hash ##
753 ### h3 trailing hash ###
761 Execute (atx headers):
762 AssertEqual SyntaxOf('# h1 space'), 'htmlH1'
763 AssertEqual SyntaxOf('#h1 nospace'), 'htmlH1'
764 AssertEqual SyntaxOf('# h1 2 spaces'), 'htmlH1'
765 AssertEqual SyntaxOf('# h1 trailing hash #'), 'htmlH1'
766 AssertEqual SyntaxOf('## h2 space'), 'htmlH2'
767 AssertEqual SyntaxOf('##h2 nospace'), 'htmlH2'
768 AssertEqual SyntaxOf('## h2 trailing hash ##'), 'htmlH2'
769 AssertEqual SyntaxOf('### h3 space'), 'htmlH3'
770 AssertEqual SyntaxOf('###h3 nospace'), 'htmlH3'
771 AssertEqual SyntaxOf('### h3 trailing hash ###'), 'htmlH3'
772 AssertEqual SyntaxOf('#### h4'), 'htmlH4'
773 AssertEqual SyntaxOf('##### h5'), 'htmlH5'
774 AssertEqual SyntaxOf('###### h6'), 'htmlH6'
783 Execute (atx headers relative positions):
784 AssertEqual SyntaxOf('# h1 before h2'), 'htmlH1'
785 AssertEqual SyntaxOf('## h2 between h1s'), 'htmlH2'
786 AssertEqual SyntaxOf('# h1 after h2'), 'htmlH1'
795 setex h1 single punctuation
798 setex h1 punctuation longer than header
799 ================================
801 Execute (setex headers):
802 AssertEqual SyntaxOf('setex h1'), 'htmlH1'
803 AssertEqual SyntaxOf('^========$'), 'htmlH1'
804 AssertEqual SyntaxOf('setex h2'), 'htmlH2'
805 AssertEqual SyntaxOf('--------'), 'htmlH2'
806 AssertEqual SyntaxOf('setex h1 single punctuation'), 'htmlH1'
807 AssertEqual SyntaxOf('^=$'), 'htmlH1'
808 AssertEqual SyntaxOf('setex h1 punctuation longer than header'), 'htmlH1'
809 AssertEqual SyntaxOf('^================================$'), 'htmlH1'
815 Execute (prevent list vs Setex confusion):
816 AssertNotEqual SyntaxOf('- not Setex'), 'htmlH2'
817 AssertNotEqual SyntaxOf('- becuase list'), 'htmlH2'
834 Execute (mixed atx and setex headers):
835 AssertEqual SyntaxOf('setex h1 before atx'), 'htmlH1'
836 AssertEqual SyntaxOf('==================='), 'htmlH1'
837 AssertEqual SyntaxOf('## atx h2'), 'htmlH2'
838 AssertEqual SyntaxOf('### atx h3'), 'htmlH3'
839 AssertEqual SyntaxOf('# atx h1'), 'htmlH1'
840 AssertEqual SyntaxOf('setex h2'), 'htmlH2'
841 AssertEqual SyntaxOf('------------------'), 'htmlH2'
849 Execute (& and > are not marked as htmlError in lists):
850 AssertEqual SyntaxOf('-'), 'mkdListItem'
851 AssertEqual SyntaxOf('1.'), 'mkdListItem'
852 AssertNotEqual SyntaxOf('&'), 'htmlError'
853 AssertNotEqual SyntaxOf('>'), 'htmlError'
859 Execute (list after line break):
860 AssertEqual SyntaxOf('1'), 'mkdListItem'
861 AssertEqual SyntaxOf('2'), 'mkdListItem'
872 Execute (HTML tag in text):
873 AssertEqual SyntaxOf('p'), 'htmlTagName'
874 AssertEqual SyntaxOf('<p>'), 'htmlTag'
875 AssertEqual SyntaxOf('</p>'), 'htmlEndTag'
876 AssertEqual SyntaxOf('span'), 'htmlTagName'
877 AssertEqual SyntaxOf('<span>'), 'htmlTag'
878 AssertEqual SyntaxOf('</span>'), 'htmlEndTag'