From c5e69c98f17081aa3f8260d8e6a37cb22e94350e Mon Sep 17 00:00:00 2001 From: Roberto Castagnola Date: Wed, 26 Jul 2023 14:49:39 +0200 Subject: [PATCH] Markdown parser: add tests for line breaks --- test/markdown_tests.vim | 97 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 4 deletions(-) diff --git a/test/markdown_tests.vim b/test/markdown_tests.vim index 749e612..9670565 100644 --- a/test/markdown_tests.vim +++ b/test/markdown_tests.vim @@ -14,7 +14,13 @@ def g:Test_Markdown() '# First level heading', '## Second level heading', '### Third level heading', - '# Heading with leading and trailing whitespaces ' + '# Heading with leading and trailing whitespaces ', + 'Multiline setext heading ', + 'of level 1', + '===', + 'Multiline setext heading\', + 'of level 2', + '---' ], # Expected text [ @@ -24,7 +30,13 @@ def g:Test_Markdown() '', 'Third level heading', '', - 'Heading with leading and trailing whitespaces' + 'Heading with leading and trailing whitespaces', + '', + 'Multiline setext heading', + 'of level 1', + '', + 'Multiline setext heading', + 'of level 2' ], # Expected text properties [ @@ -34,7 +46,13 @@ def g:Test_Markdown() [], [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 19}], [], - [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 45}] + [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 45}], + [], + [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 24}], + [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 10}], + [], + [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 24}], + [{'col': 1, 'type': 'LspMarkdownHeading', 'length': 10}], ] ], [ @@ -178,6 +196,77 @@ def g:Test_Markdown() [ [], [], [] ] + ], + [ + # line breaks + # Input text + [ + 'This paragraph contains ', + 'a soft line break', + '', + 'This paragraph contains ', + 'an hard line break', + '', + 'This paragraph contains an emphasis _before_\', + 'an hard line break', + '', + 'This paragraph contains an emphasis ', + '_after_ an hard line break', + '', + 'This paragraph _contains\', + 'an emphasis_ with an hard line break in the middle', + '', + '→ This paragraph contains an hard line break ', + 'and starts with the multibyte character "\u2192"', + '', + 'Line breaks `', + 'do\', + 'not ', + 'occur', + '` inside code spans' + ], + # Expected text + [ + 'This paragraph contains a soft line break', + '', + 'This paragraph contains', + 'an hard line break', + '', + 'This paragraph contains an emphasis before', + 'an hard line break', + '', + 'This paragraph contains an emphasis', + 'after an hard line break', + '', + 'This paragraph contains', + 'an emphasis with an hard line break in the middle', + '', + '→ This paragraph contains an hard line break', + 'and starts with the multibyte character "\u2192"', + '', + 'Line breaks do\ not occur inside code spans' + ], + # Expected text properties + [ + [], + [], + [], + [], + [], + [{'col': 37, 'type': 'LspMarkdownItalic', 'length': 6}], + [], + [], + [], + [{'col': 1, 'type': 'LspMarkdownItalic', 'length': 5}], + [], + [{'col': 16, 'type': 'LspMarkdownItalic', 'length': 8}], + [{'col': 1, 'type': 'LspMarkdownItalic', 'length': 11}], + [], + [], + [], + [], + [{'col': 13, 'type': 'LspMarkdownCode', 'length': 15}] + ] ] ] @@ -198,4 +287,4 @@ def g:StartLangServer(): bool return true enddef -# vim: shiftwidth=2 softtabstop=2 noexpandtab +# vim: tabstop=8 shiftwidth=2 softtabstop=2 noexpandtab -- 2.44.0