diff options
author | Andrey Makarov <ph.makarov@gmail.com> | 2022-10-05 21:03:10 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 14:03:10 -0400 |
commit | 6505bd347df557713061d4e84cf9548d104622d9 (patch) | |
tree | 8f48f1d066b9e807b2c5550edb5f743e7cc7fa01 /tests/stdlib | |
parent | 594e93a66bd19297d23d3328a3f35aa6ac3789af (diff) | |
download | Nim-6505bd347df557713061d4e84cf9548d104622d9.tar.gz |
Markdown indented code blocks (#20473)
* Implement Markdown indented code blocks Additional indentation of 4 spaces makes a block an "indented code block" (monospaced text without syntax highlighting). Also `::` RST syntax for code blocks is disabled. So instead of ```rst see:: Some code ``` the code block should be written as ```markdown see: Some code ``` * Migrate RST literal blocks :: to Markdown's ones
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/trst.nim | 63 | ||||
-rw-r--r-- | tests/stdlib/trstgen.nim | 2 |
2 files changed, 59 insertions, 6 deletions
diff --git a/tests/stdlib/trst.nim b/tests/stdlib/trst.nim index 818f8b8dc..3575d17aa 100644 --- a/tests/stdlib/trst.nim +++ b/tests/stdlib/trst.nim @@ -7,6 +7,8 @@ discard """ [Suite] RST indentation +[Suite] Markdown indentation + [Suite] Warnings [Suite] RST include directive @@ -124,12 +126,12 @@ suite "RST parsing": check(dedent""" Paragraph:: - >x""".toAst == expected) + >x""".toAst(rstOptions = preferRst) == expected) check(dedent""" Paragraph:: - >x""".toAst == expected) + >x""".toAst(rstOptions = preferRst) == expected) test "RST quoted literal blocks, :: at a separate line": let expected = @@ -148,7 +150,7 @@ suite "RST parsing": :: >x - >>y""".toAst == expected) + >>y""".toAst(rstOptions = preferRst) == expected) check(dedent""" Paragraph @@ -156,7 +158,7 @@ suite "RST parsing": :: >x - >>y""".toAst == expected) + >>y""".toAst(rstOptions = preferRst) == expected) test "Markdown quoted blocks": check(dedent""" @@ -779,7 +781,7 @@ suite "RST parsing": code - """.toAst == + """.toAst(rstOptions = preferRst) == dedent""" rnInner rnLeaf 'Check' @@ -788,6 +790,32 @@ suite "RST parsing": rnLeaf 'code' """) + test "Markdown indented code blocks": + check(dedent""" + See + + some code""".toAst == + dedent""" + rnInner + rnInner + rnLeaf 'See' + rnLiteralBlock + rnLeaf 'some code' + """) + + # not a code block -- no blank line before: + check(dedent""" + See + some code""".toAst == + dedent""" + rnInner + rnLeaf 'See' + rnLeaf ' ' + rnLeaf 'some' + rnLeaf ' ' + rnLeaf 'code' + """) + suite "RST tables": test "formatting in tables works": @@ -1238,6 +1266,31 @@ suite "RST indentation": rnLeaf 'term3definition2' """) +suite "Markdown indentation": + test "Markdown paragraph indentation": + # Additional spaces (<=3) of indentation does not break the paragraph. + # TODO: in 2nd case de-indentation causes paragraph to break, this is + # reasonable but does not seem to conform the Markdown spec. + check(dedent""" + Start1 + stop1 + + Start2 + stop2 + """.toAst == + dedent""" + rnInner + rnParagraph + rnLeaf 'Start1' + rnLeaf ' ' + rnLeaf 'stop1' + rnParagraph + rnLeaf 'Start2' + rnParagraph + rnLeaf 'stop2' + rnLeaf ' ' + """) + suite "Warnings": test "warnings for broken footnotes/links/substitutions": let input = dedent""" diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim index b33ee82a8..a25d903db 100644 --- a/tests/stdlib/trstgen.nim +++ b/tests/stdlib/trstgen.nim @@ -632,7 +632,7 @@ Test literal block :: check """ - let output1 = input1.toHtml + let output1 = input1.toHtml(preferRst) doAssert "<pre>" in output1 test "Markdown code block": |