3 # Unit tests for the Github Flavored Markdown parser
5 import '../autoload/lsp/markdown.vim' as md
7 # Test for different markdowns
9 var tests: list<list<list<any>>> = [
14 '# First level heading',
15 '## Second level heading',
16 '### Third level heading'
20 'First level heading',
22 'Second level heading',
26 # Expected text properties
28 [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 19}],
30 [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 20}],
32 [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 19}]
39 'This **word** should be bold',
41 '**This line should be bold**',
43 'This __word__ should be bold',
45 '__This line should be bold__'
49 'This word should be bold',
51 'This line should be bold',
53 'This word should be bold',
55 'This line should be bold'
57 # Expected text properties
59 [{'col': 6, 'type': 'LspMarkdownBold', 'length': 4}],
61 [{'col': 1, 'type': 'LspMarkdownBold', 'length': 24}],
63 [{'col': 6, 'type': 'LspMarkdownBold', 'length': 4}],
65 [{'col': 1, 'type': 'LspMarkdownBold', 'length': 24}]
72 'This *word* should be italic',
74 '*This line should be italic*',
76 'This _word_ should be italic',
78 '_This line should be italic_'
82 'This word should be italic',
84 'This line should be italic',
86 'This word should be italic',
88 'This line should be italic'
90 # Expected text properties
92 [{'col': 6, 'type': 'LspMarkdownItalic', 'length': 4}],
94 [{'col': 1, 'type': 'LspMarkdownItalic', 'length': 26}],
96 [{'col': 6, 'type': 'LspMarkdownItalic', 'length': 4}],
98 [{'col': 1, 'type': 'LspMarkdownItalic', 'length': 26}]
102 # strikethrough text style
105 'This ~word~ should be strikethrough',
107 '~This line should be strikethrough~'
111 'This word should be strikethrough',
113 'This line should be strikethrough'
115 # Expected text properties
117 [{'col': 6, 'type': 'LspMarkdownStrikeThrough', 'length': 4}],
119 [{'col': 1, 'type': 'LspMarkdownStrikeThrough', 'length': 33}]
123 # bold and nested italic text style
126 '**This _word_ should be bold and italic**',
130 'This word should be bold and italic',
132 # Expected text properties
135 {'col': 1, 'type': 'LspMarkdownBold', 'length': 35},
136 {'col': 6, 'type': 'LspMarkdownItalic', 'length': 4}
141 # all bold and italic text style
144 '***This line should be all bold and italic***',
148 'This line should be all bold and italic',
150 # Expected text properties
153 {'col': 1, 'type': 'LspMarkdownItalic', 'length': 39},
154 {'col': 1, 'type': 'LspMarkdownBold', 'length': 39}
160 # FIXME: The text is not quoted
163 'Text that is not quoted',
168 'Text that is not quoted',
172 # Expected text properties
179 var doc: dict<list<any>>
180 var text_result: list<string>
181 var props_result: list<list<dict<any>>>
183 doc = md.ParseMarkdown(t[0])
184 text_result = doc.content->deepcopy()->map((_, v) => v.text)
185 props_result = doc.content->deepcopy()->map((_, v) => v.props)
186 assert_equal(t[1], text_result, t[0]->string())
187 assert_equal(t[2], props_result, t[0]->string())
191 # Only here to because the test runner needs it
192 def g:StartLangServer(): bool
196 # vim: shiftwidth=2 softtabstop=2 noexpandtab