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
4 unlet! g:vim_markdown_math
10 AssertNotEqual SyntaxOf('a'), 'htmlBold'
11 AssertEqual SyntaxOf('b'), 'htmlBold'
12 AssertNotEqual SyntaxOf('c'), 'htmlBold'
18 AssertNotEqual SyntaxOf('a'), 'htmlBold'
19 AssertEqual SyntaxOf('b'), 'htmlBold'
20 AssertNotEqual SyntaxOf('c'), 'htmlBold'
26 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
27 AssertEqual SyntaxOf('b'), 'htmlItalic'
28 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
34 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
35 AssertEqual SyntaxOf('b'), 'htmlItalic'
36 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
41 Execute (italic text has underscores):
42 AssertEqual SyntaxOf('a'), 'htmlItalic'
43 AssertEqual SyntaxOf('b'), 'htmlItalic'
48 Execute (not italic with escaped asterisks):
49 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
50 AssertNotEqual SyntaxOf('b'), 'htmlItalic'
51 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
56 Execute (not italic with escaped underscores):
57 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
58 AssertNotEqual SyntaxOf('b'), 'htmlItalic'
59 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
64 Execute (italic with escaped underscores):
65 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
66 AssertEqual SyntaxOf('b'), 'htmlItalic'
67 AssertEqual SyntaxOf('c'), 'htmlItalic'
68 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
73 Execute (not italic underscores within text):
74 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
75 AssertNotEqual SyntaxOf('b'), 'htmlItalic'
76 AssertNotEqual SyntaxOf('c'), 'htmlItalic'
81 Execute (italic with escaped asterisks):
82 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
83 AssertEqual SyntaxOf('b'), 'htmlItalic'
84 AssertEqual SyntaxOf('c'), 'htmlItalic'
85 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
90 Execute (bold with escaped underscores):
91 AssertNotEqual SyntaxOf('a'), 'htmlBold'
92 AssertEqual SyntaxOf('b'), 'htmlBold'
93 AssertEqual SyntaxOf('c'), 'htmlBold'
94 AssertNotEqual SyntaxOf('d'), 'htmlBold'
100 Execute (italic with underscores in multiple lines):
101 AssertEqual SyntaxOf('a'), 'htmlItalic'
102 AssertEqual SyntaxOf('b'), 'htmlItalic'
103 AssertEqual SyntaxOf('c'), 'htmlItalic'
104 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
110 Execute (bold with underscores in multiple lines):
111 AssertEqual SyntaxOf('a'), 'htmlBold'
112 AssertEqual SyntaxOf('b'), 'htmlBold'
113 AssertEqual SyntaxOf('c'), 'htmlBold'
114 AssertNotEqual SyntaxOf('d'), 'htmlBold'
120 Execute (bold italic with underscores in multiple lines):
121 AssertEqual SyntaxOf('a'), 'htmlBoldItalic'
122 AssertEqual SyntaxOf('b'), 'htmlBoldItalic'
123 AssertEqual SyntaxOf('c'), 'htmlBoldItalic'
124 AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
130 Execute (italic with asterisks in multiple lines):
131 AssertEqual SyntaxOf('a'), 'htmlItalic'
132 AssertEqual SyntaxOf('b'), 'htmlItalic'
133 AssertEqual SyntaxOf('c'), 'htmlItalic'
134 AssertNotEqual SyntaxOf('d'), 'htmlItalic'
140 Execute (bold with asterisks in multiple lines):
141 AssertEqual SyntaxOf('a'), 'htmlBold'
142 AssertEqual SyntaxOf('b'), 'htmlBold'
143 AssertEqual SyntaxOf('c'), 'htmlBold'
144 AssertNotEqual SyntaxOf('d'), 'htmlBold'
150 Execute (bold italic with asterisks in multiple lines):
151 AssertEqual SyntaxOf('a'), 'htmlBoldItalic'
152 AssertEqual SyntaxOf('b'), 'htmlBoldItalic'
153 AssertEqual SyntaxOf('c'), 'htmlBoldItalic'
154 AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
159 Execute (not italic with an asterisk):
160 AssertNotEqual SyntaxOf('a'), 'htmlItalic'
165 Execute (not bold with double underscores):
166 AssertNotEqual SyntaxOf('_'), 'htmlBold'
167 AssertNotEqual SyntaxOf('a'), 'htmlBold'
168 AssertNotEqual SyntaxOf('b'), 'htmlBold'
175 Execute (link with title):
176 AssertEqual SyntaxOf('a'), 'mkdLink'
177 AssertEqual SyntaxOf('b'), 'mkdURL'
183 Execute (link text with newline):
184 AssertEqual SyntaxOf('a'), 'mkdLink'
185 AssertEqual SyntaxOf('b'), 'mkdLink'
186 AssertEqual SyntaxOf('c'), 'mkdURL'
193 Execute (parenthesis not in link):
194 AssertNotEqual SyntaxOf('a'), 'mkdURL'
195 AssertNotEqual SyntaxOf('b'), 'mkdURL'
200 Execute (multiple links on a line):
201 AssertNotEqual SyntaxOf('c'), 'mkdLink'
202 AssertNotEqual SyntaxOf('c'), 'mkdURL'
207 Execute (space is not allowed between link text and parenthesis):
208 AssertNotEqual SyntaxOf('a'), 'mkdLink'
209 AssertNotEqual SyntaxOf('b'), 'mkdURL'
214 Execute (conceal link):
216 setlocal conceallevel=2
217 AssertEqual synconcealed(1, 1)[0], 1
218 AssertEqual synconcealed(1, 2)[0], 0
219 AssertEqual synconcealed(1, 3)[0], 1
220 AssertEqual synconcealed(1, 4)[0], 1
221 AssertEqual synconcealed(1, 4)[0], 1
222 AssertEqual synconcealed(1, 5)[0], 1
223 AssertEqual synconcealed(1, 6)[0], 1
224 setlocal conceallevel=0
227 Execute (disable conceal):
229 let g:vim_markdown_conceal=0
231 setlocal conceallevel=2
232 AssertEqual synconcealed(1, 1)[0], 0
233 AssertEqual synconcealed(1, 2)[0], 0
234 AssertEqual synconcealed(1, 3)[0], 0
235 AssertEqual synconcealed(1, 4)[0], 0
236 AssertEqual synconcealed(1, 4)[0], 0
237 AssertEqual synconcealed(1, 5)[0], 0
238 AssertEqual synconcealed(1, 6)[0], 0
240 let g:vim_markdown_conceal=1
242 AssertEqual synconcealed(1, 1)[0], 1
243 AssertEqual synconcealed(1, 2)[0], 0
244 AssertEqual synconcealed(1, 3)[0], 1
245 AssertEqual synconcealed(1, 4)[0], 1
246 AssertEqual synconcealed(1, 4)[0], 1
247 AssertEqual synconcealed(1, 5)[0], 1
248 AssertEqual synconcealed(1, 6)[0], 1
250 setlocal conceallevel=0
251 unlet g:vim_markdown_conceal
261 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
262 AssertEqual SyntaxOf('<'), 'mkdDelimiter'
263 AssertEqual SyntaxOf('b'), 'mkdInlineURL'
264 AssertEqual SyntaxOf('>'), 'mkdDelimiter'
265 AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
270 Execute (autolink with domain starting with a number):
271 AssertEqual SyntaxOf('12monkeys'), 'mkdInlineURL'
276 Execute (autolink with scheme case is insensitive):
277 AssertEqual SyntaxOf('a'), 'mkdInlineURL'
282 Execute (autolink without scheme is not a link):
283 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
291 Execute (autolink with space is not a link):
292 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
293 AssertNotEqual SyntaxOf('b'), 'mkdInlineURL'
294 AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
295 AssertNotEqual SyntaxOf('d'), 'mkdInlineURL'
296 AssertNotEqual SyntaxOf('e'), 'mkdInlineURL'
301 Execute (autolinks can be backslash escaped):
302 AssertNotEqual SyntaxOf('<'), 'mkdDelimiter'
307 Execute (autolink in parenthesis):
308 AssertNotEqual SyntaxOf('a'), 'mkdInlineURL'
309 AssertEqual SyntaxOf('('), 'mkdDelimiter'
310 AssertEqual SyntaxOf('b'), 'mkdInlineURL'
311 AssertEqual SyntaxOf(')'), 'mkdDelimiter'
312 AssertNotEqual SyntaxOf('c'), 'mkdInlineURL'
315 [![a](http://b)](http://c)
317 Execute (autolink in link text):
318 AssertEqual SyntaxOf('!'), 'mkdDelimiter'
319 AssertEqual SyntaxOf('a'), 'mkdLink'
320 AssertEqual SyntaxOf('b'), 'mkdURL'
321 AssertEqual SyntaxOf('c'), 'mkdURL'
330 Execute (code blocks can be fenced with tildes):
331 AssertEqual SyntaxOf('c'), 'mkdCode'
338 Execute (code blocks can be fenced with tildes longer than 3):
339 AssertEqual SyntaxOf('c'), 'mkdCode'
346 Execute (code blocks can be fenced with backticks longer than 3):
347 AssertEqual SyntaxOf('c'), 'mkdCode'
354 Execute (code blocks can have a language specifier):
355 AssertEqual SyntaxOf('c'), 'mkdCode'
364 Execute (code blocks can be fenced with backticks and a language specifier):
365 AssertEqual SyntaxOf('code'), 'mkdCode'
366 AssertNotEqual SyntaxOf('text'), 'mkdCode'
376 Execute (indent code blocks):
377 AssertNotEqual SyntaxOf('a'), 'mkdCode'
378 AssertEqual SyntaxOf('b'), 'mkdCode'
379 AssertEqual SyntaxOf('c'), 'mkdCode'
388 Execute (indent code blocks after header):
389 AssertNotEqual SyntaxOf('a'), 'mkdCode'
390 AssertNotEqual SyntaxOf('b'), 'mkdCode'
391 AssertEqual SyntaxOf('c'), 'mkdCode'
400 Execute (indent code blocks after list):
401 AssertNotEqual SyntaxOf('a'), 'mkdCode'
402 AssertNotEqual SyntaxOf('b'), 'mkdCode'
403 AssertEqual SyntaxOf('c'), 'mkdCode'
409 Execute (indent code block at beginning of file):
410 AssertEqual SyntaxOf('a'), 'mkdCode'
411 AssertEqual SyntaxOf('b'), 'mkdCode'
424 Execute (fenced code block syntax with a language specifier):
425 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
427 AssertEqual SyntaxOf('include'), 'cInclude'
428 AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
429 AssertEqual SyntaxOf('def'), 'rubyDefine'
452 Execute (fenced code block syntax with a language specifier after whitespace):
453 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
455 AssertEqual SyntaxOf('include'), 'cInclude'
456 AssertEqual SyntaxOf('code'), 'mkdSnippetCPP'
457 AssertEqual SyntaxOf('g:a'), 'vimVar'
458 AssertEqual SyntaxOf('def'), 'rubyDefine'
459 AssertNotEqual SyntaxOf('class'), 'rubyClass'
470 Execute (fenced code block syntax with alias language specifier):
471 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
473 AssertEqual SyntaxOf('g:a'), 'vimVar'
474 AssertEqual SyntaxOf('g:b'), 'vimVar'
481 Execute (fenced code block languages setting):
482 let g:vim_markdown_fenced_languages = ['csharp=cs']
483 source ../ftplugin/markdown.vim
484 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
486 AssertEqual SyntaxOf('foo'), 'csString'
487 unlet g:vim_markdown_fenced_languages
494 Execute (fenced code block includes language syntax with reopening same buffer):
495 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
500 set filetype=markdown
501 execute "normal! i```vim\<cr>let g:a = 1\<cr>```"
503 AssertEqual SyntaxOf('g:a'), 'vimVar'
510 Execute (fenced code block syntax with an unknown language specifier):
511 let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
513 AssertEqual SyntaxOf('code'), 'mkdSnippetA_B_'
522 Execute (first = or - in fenced code block is not setex headers):
523 AssertEqual SyntaxOf('='), 'mkdCode'
524 AssertEqual SyntaxOf('-'), 'mkdCode'
531 Execute (fenced code block with extended info strings):
532 AssertEqual SyntaxOf('a'), 'mkdCode'
534 # Code Blocks in pre and code tag
541 Execute (code block in pre tag):
542 AssertEqual SyntaxOf('a'), 'mkdCode'
549 Execute (code block in code tag):
550 AssertEqual SyntaxOf('a'), 'mkdCode'
557 Execute (not code block in escaped pre tag):
558 AssertNotEqual SyntaxOf('a'), 'mkdCode'
565 Execute (not code block in escaped code tag):
566 AssertNotEqual SyntaxOf('a'), 'mkdCode'
577 AssertNotEqual SyntaxOf('x'), 'mkdMath'
578 AssertNotEqual SyntaxOf('y'), 'mkdMath'
579 let g:vim_markdown_math=1
581 AssertNotEqual SyntaxOf('a'), 'mkdMath'
582 AssertNotEqual SyntaxOf('b'), 'mkdMath'
583 AssertNotEqual SyntaxOf('c'), 'mkdMath'
584 AssertNotEqual SyntaxOf('d'), 'mkdMath'
585 AssertNotEqual SyntaxOf('e'), 'mkdMath'
586 AssertNotEqual SyntaxOf('f'), 'mkdMath'
587 AssertEqual SyntaxOf('x'), 'mkdMath'
588 AssertEqual SyntaxOf('y'), 'mkdMath'
589 let g:vim_markdown_math=0
591 AssertNotEqual SyntaxOf('x'), 'mkdMath'
592 AssertNotEqual SyntaxOf('y'), 'mkdMath'
603 Execute (multiline math):
604 let g:vim_markdown_math=1
606 AssertNotEqual SyntaxOf('a'), 'mkdMath'
607 AssertEqual SyntaxOf('b'), 'mkdMath'
608 AssertNotEqual SyntaxOf('c'), 'mkdMath'
614 Execute (math tex highlighting):
615 let g:vim_markdown_math=0
617 AssertNotEqual SyntaxOf('sqrt'), 'texStatement'
618 AssertNotEqual SyntaxOf('frac'), 'texStatement'
619 let g:vim_markdown_math=1
621 AssertEqual SyntaxOf('sqrt'), 'texStatement'
622 AssertEqual SyntaxOf('frac'), 'texStatement'
627 Execute (math ends with $):
628 let g:vim_markdown_math=1
630 AssertEqual SyntaxOf('a'), 'mkdMath'
631 AssertEqual SyntaxOf('b'), 'mkdMath'
632 AssertNotEqual SyntaxOf('c')[0:2], 'tex'
637 Execute (math ends with $$):
638 let g:vim_markdown_math=1
640 AssertEqual SyntaxOf('a'), 'mkdMath'
641 AssertEqual SyntaxOf('b'), 'mkdMath'
642 AssertNotEqual SyntaxOf('c')[0:2], 'tex'
651 Execute (YAML frontmatter is controlled by the option):
652 AssertNotEqual SyntaxOf('a')[0:3], 'yaml'
653 let g:vim_markdown_frontmatter=1
655 AssertEqual SyntaxOf('a')[0:3], 'yaml'
656 let g:vim_markdown_frontmatter=0
658 AssertNotEqual SyntaxOf('a')[0:3], 'yaml'
666 Execute (YAML frontmatter only works if it's the first thing in the file):
667 let g:vim_markdown_frontmatter=1
669 AssertNotEqual SyntaxOf('a')[0:3], 'yaml'
678 Execute (rules are not mistaken by YAML frontmatter delimiters):
679 let g:vim_markdown_frontmatter=1
681 AssertEqual SyntaxAt(5, 1), 'mkdRule'
682 unlet g:vim_markdown_frontmatter
691 Execute (TOML frontmatter is controlled by the option):
693 AssertNotEqual SyntaxOf('b'), 'tomlString'
694 let g:vim_markdown_toml_frontmatter=1
696 AssertEqual SyntaxOf('b'), 'tomlString'
697 let g:vim_markdown_toml_frontmatter=0
699 AssertNotEqual SyntaxOf('b'), 'tomlString'
707 Execute (TOML frontmatter only works if it's the first thing in the file):
708 let g:vim_markdown_toml_frontmatter=1
710 AssertNotEqual SyntaxOf('b'), 'tomlString'
711 unlet g:vim_markdown_toml_frontmatter
720 Execute (JSON frontmatter is controlled by the option):
722 AssertNotEqual SyntaxOf('a'), 'jsonKeyword'
723 let g:vim_markdown_json_frontmatter=1
725 AssertEqual SyntaxOf('a'), 'jsonKeyword'
726 let g:vim_markdown_json_frontmatter=0
728 AssertNotEqual SyntaxOf('a'), 'jsonKeyword'
736 Execute (JSON frontmatter only works if it's the first thing in the file):
737 let g:vim_markdown_json_frontmatter=1
739 AssertNotEqual SyntaxOf('a'), 'jsonKeyword'
740 unlet g:vim_markdown_json_frontmatter
751 Execute (header title starts with #):
752 AssertEqual SyntaxOf('a'), 'htmlH1'
753 AssertEqual SyntaxOf('b'), 'htmlH2'
768 ## h2 trailing hash ##
774 ### h3 trailing hash ###
782 Execute (atx headers):
783 AssertEqual SyntaxOf('# h1 space'), 'htmlH1'
784 AssertEqual SyntaxOf('#h1 nospace'), 'htmlH1'
785 AssertEqual SyntaxOf('# h1 2 spaces'), 'htmlH1'
786 AssertEqual SyntaxOf('# h1 trailing hash #'), 'htmlH1'
787 AssertEqual SyntaxOf('## h2 space'), 'htmlH2'
788 AssertEqual SyntaxOf('##h2 nospace'), 'htmlH2'
789 AssertEqual SyntaxOf('## h2 trailing hash ##'), 'htmlH2'
790 AssertEqual SyntaxOf('### h3 space'), 'htmlH3'
791 AssertEqual SyntaxOf('###h3 nospace'), 'htmlH3'
792 AssertEqual SyntaxOf('### h3 trailing hash ###'), 'htmlH3'
793 AssertEqual SyntaxOf('#### h4'), 'htmlH4'
794 AssertEqual SyntaxOf('##### h5'), 'htmlH5'
795 AssertEqual SyntaxOf('###### h6'), 'htmlH6'
804 Execute (atx headers relative positions):
805 AssertEqual SyntaxOf('# h1 before h2'), 'htmlH1'
806 AssertEqual SyntaxOf('## h2 between h1s'), 'htmlH2'
807 AssertEqual SyntaxOf('# h1 after h2'), 'htmlH1'
816 setex h1 single punctuation
819 setex h1 punctuation longer than header
820 ================================
822 Execute (setex headers):
823 AssertEqual SyntaxOf('setex h1'), 'htmlH1'
824 AssertEqual SyntaxOf('^========$'), 'htmlH1'
825 AssertEqual SyntaxOf('setex h2'), 'htmlH2'
826 AssertEqual SyntaxOf('--------'), 'htmlH2'
827 AssertEqual SyntaxOf('setex h1 single punctuation'), 'htmlH1'
828 AssertEqual SyntaxOf('^=$'), 'htmlH1'
829 AssertEqual SyntaxOf('setex h1 punctuation longer than header'), 'htmlH1'
830 AssertEqual SyntaxOf('^================================$'), 'htmlH1'
836 Execute (prevent list vs Setex confusion):
837 AssertNotEqual SyntaxOf('- not Setex'), 'htmlH2'
838 AssertNotEqual SyntaxOf('- becuase list'), 'htmlH2'
855 Execute (mixed atx and setex headers):
856 AssertEqual SyntaxOf('setex h1 before atx'), 'htmlH1'
857 AssertEqual SyntaxOf('==================='), 'htmlH1'
858 AssertEqual SyntaxOf('## atx h2'), 'htmlH2'
859 AssertEqual SyntaxOf('### atx h3'), 'htmlH3'
860 AssertEqual SyntaxOf('# atx h1'), 'htmlH1'
861 AssertEqual SyntaxOf('setex h2'), 'htmlH2'
862 AssertEqual SyntaxOf('------------------'), 'htmlH2'
870 Execute (& and > are not marked as htmlError in lists):
871 AssertEqual SyntaxOf('-'), 'mkdListItem'
872 AssertEqual SyntaxOf('1.'), 'mkdListItem'
873 AssertNotEqual SyntaxOf('&'), 'htmlError'
874 AssertNotEqual SyntaxOf('>'), 'htmlError'
880 Execute (list after line break):
881 AssertEqual SyntaxOf('1'), 'mkdListItem'
882 AssertEqual SyntaxOf('2'), 'mkdListItem'
893 Execute (HTML tag in text):
894 AssertEqual SyntaxOf('p'), 'htmlTagName'
895 AssertEqual SyntaxOf('<p>'), 'htmlTag'
896 AssertEqual SyntaxOf('</p>'), 'htmlEndTag'
897 AssertEqual SyntaxOf('span'), 'htmlTagName'
898 AssertEqual SyntaxOf('<span>'), 'htmlTag'
899 AssertEqual SyntaxOf('</span>'), 'htmlEndTag'