X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/73c5dd90794911db1bb806c61a171844e8b6917d..6df8cb9ec2483fdfc7e57daa083b8cf2be05ffee:/test/syntax.vader?ds=inline diff --git a/test/syntax.vader b/test/syntax.vader index 2f5f78c..5ce94fc 100644 --- a/test/syntax.vader +++ b/test/syntax.vader @@ -167,6 +167,234 @@ Execute (not bold with double underscores): AssertNotEqual SyntaxOf('a'), 'htmlBold' AssertNotEqual SyntaxOf('b'), 'htmlBold' +Given markdown; +_a_ + +Execute (conceal italic): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +*a* + +Execute (conceal italic): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +__a__ + +Execute (conceal bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +**a** + +Execute (conceal bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 1 + AssertEqual synconcealed(1, 5)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +___a___ + +Execute (conceal italic bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + AssertEqual synconcealed(1, 6)[0], 0 + AssertEqual synconcealed(1, 7)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + +Given markdown; +***a*** + +Execute (conceal italic bold): + if has('conceal') + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + setlocal conceallevel=0 + endif + +Execute (disable conceal): + if has('conceal') + let g:vim_markdown_conceal=0 + syn off | syn on + setlocal conceallevel=2 + AssertEqual synconcealed(1, 1)[0], 0 + AssertEqual synconcealed(1, 2)[0], 0 + AssertEqual synconcealed(1, 3)[0], 0 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 0 + AssertEqual synconcealed(1, 6)[0], 0 + AssertEqual synconcealed(1, 7)[0], 0 + + let g:vim_markdown_conceal=1 + syn off | syn on + AssertEqual synconcealed(1, 1)[0], 1 + AssertEqual synconcealed(1, 2)[0], 1 + AssertEqual synconcealed(1, 3)[0], 1 + AssertEqual synconcealed(1, 4)[0], 0 + AssertEqual synconcealed(1, 5)[0], 1 + AssertEqual synconcealed(1, 6)[0], 1 + AssertEqual synconcealed(1, 7)[0], 1 + + setlocal conceallevel=0 + unlet g:vim_markdown_conceal + syn off | syn on + endif + # Links Given markdown; @@ -185,6 +413,21 @@ Execute (link text with newline): AssertEqual SyntaxOf('b'), 'mkdLink' AssertEqual SyntaxOf('c'), 'mkdURL' +Given markdown; +[a] b [c](d) + +Execute (link text with bracket sections): + AssertNotEqual SyntaxOf('a'), 'mkdLink' + AssertNotEqual SyntaxOf('b'), 'mkdLink' + AssertEqual SyntaxOf('c'), 'mkdLink' + AssertEqual SyntaxOf('d'), 'mkdURL' + +Given markdown; +[^a]: b + +Execute (footnote is not link): + AssertNotEqual SyntaxOf('a'), 'mkdLinkDef' + Given markdown; (a) @@ -386,6 +629,14 @@ Execute (link in blockquote): AssertEqual SyntaxOf('a'), 'mkdLink' AssertEqual SyntaxOf('foo'), 'mkdInlineURL' +Given markdown; +[https://domain.tld](https://domain.com) not_a_link + +Execute (link with url title): + AssertEqual SyntaxOf('https://domain.tld'), 'mkdInlineURL' + AssertEqual SyntaxOf('https://domain.com'), 'mkdInlineURL' + AssertNotEqual SyntaxOf('not_a_link'), 'mkdInlineURL' + # Code Blocks Given markdown; @@ -631,6 +882,32 @@ a Execute (not code block in escaped code tag): AssertNotEqual SyntaxOf('a'), 'mkdCode' +# Code quotes + +Given markdown; +`a` + +Execute (code in code quotes): + AssertEqual SyntaxOf('a'), 'mkdCode' + +Given markdown; +`a\` b `c\` d + +Execute (code quotes not escaped ending with backslash): + AssertEqual SyntaxOf('a\'), 'mkdCode' + AssertNotEqual SyntaxOf('b'), 'mkdCode' + AssertEqual SyntaxOf('c\'), 'mkdCode' + AssertNotEqual SyntaxOf('d'), 'mkdCode' + +Given markdown; +``a\`` b ``c`\`1`` d + +Execute (double code quotes not escaped ending with backslash): + AssertEqual SyntaxOf('a\'), 'mkdCode' + AssertNotEqual SyntaxOf('b'), 'mkdCode' + AssertEqual SyntaxOf('c`\\`1'), 'mkdCode' + AssertNotEqual SyntaxOf('d'), 'mkdCode' + # Math Given markdown; @@ -888,19 +1165,19 @@ Given markdown; ###### h6 Execute (atx headers): - AssertEqual SyntaxOf('# h1 space'), 'htmlH1' - AssertEqual SyntaxOf('#h1 nospace'), 'htmlH1' - AssertEqual SyntaxOf('# h1 2 spaces'), 'htmlH1' - AssertEqual SyntaxOf('# h1 trailing hash #'), 'htmlH1' - AssertEqual SyntaxOf('## h2 space'), 'htmlH2' - AssertEqual SyntaxOf('##h2 nospace'), 'htmlH2' - AssertEqual SyntaxOf('## h2 trailing hash ##'), 'htmlH2' - AssertEqual SyntaxOf('### h3 space'), 'htmlH3' - AssertEqual SyntaxOf('###h3 nospace'), 'htmlH3' - AssertEqual SyntaxOf('### h3 trailing hash ###'), 'htmlH3' - AssertEqual SyntaxOf('#### h4'), 'htmlH4' - AssertEqual SyntaxOf('##### h5'), 'htmlH5' - AssertEqual SyntaxOf('###### h6'), 'htmlH6' + AssertEqual SyntaxOf(' h1 space'), 'htmlH1' + AssertEqual SyntaxOf('h1 nospace'), 'htmlH1' + AssertEqual SyntaxOf(' h1 2 spaces'), 'htmlH1' + AssertEqual SyntaxOf(' h1 trailing hash '), 'htmlH1' + AssertEqual SyntaxOf(' h2 space'), 'htmlH2' + AssertEqual SyntaxOf('h2 nospace'), 'htmlH2' + AssertEqual SyntaxOf(' h2 trailing hash '), 'htmlH2' + AssertEqual SyntaxOf(' h3 space'), 'htmlH3' + AssertEqual SyntaxOf('h3 nospace'), 'htmlH3' + AssertEqual SyntaxOf(' h3 trailing hash '), 'htmlH3' + AssertEqual SyntaxOf(' h4'), 'htmlH4' + AssertEqual SyntaxOf(' h5'), 'htmlH5' + AssertEqual SyntaxOf(' h6'), 'htmlH6' Given markdown; # h1 before h2 @@ -910,9 +1187,9 @@ Given markdown; # h1 after h2 Execute (atx headers relative positions): - AssertEqual SyntaxOf('# h1 before h2'), 'htmlH1' - AssertEqual SyntaxOf('## h2 between h1s'), 'htmlH2' - AssertEqual SyntaxOf('# h1 after h2'), 'htmlH1' + AssertEqual SyntaxOf(' h1 before h2'), 'htmlH1' + AssertEqual SyntaxOf(' h2 between h1s'), 'htmlH2' + AssertEqual SyntaxOf(' h1 after h2'), 'htmlH1' Given markdown; setex h1 @@ -963,9 +1240,9 @@ setex h2 Execute (mixed atx and setex headers): AssertEqual SyntaxOf('setex h1 before atx'), 'htmlH1' AssertEqual SyntaxOf('==================='), 'htmlH1' - AssertEqual SyntaxOf('## atx h2'), 'htmlH2' - AssertEqual SyntaxOf('### atx h3'), 'htmlH3' - AssertEqual SyntaxOf('# atx h1'), 'htmlH1' + AssertEqual SyntaxOf(' atx h2'), 'htmlH2' + AssertEqual SyntaxOf(' atx h3'), 'htmlH3' + AssertEqual SyntaxOf(' atx h1'), 'htmlH1' AssertEqual SyntaxOf('setex h2'), 'htmlH2' AssertEqual SyntaxOf('------------------'), 'htmlH2'