summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorAndrey Makarov <ph.makarov@gmail.com>2023-04-18 11:37:47 +0300
committerGitHub <noreply@github.com>2023-04-18 10:37:47 +0200
commit24b6378382f4bcde3b354f0a8137604192c7570f (patch)
tree1e79a1bc20cd83daf9f74cb972b2d52a0fca93be /tests/stdlib
parent2f547afb0f2ca38d317d95cd9fc17fafc6b403df (diff)
downloadNim-24b6378382f4bcde3b354f0a8137604192c7570f.tar.gz
Fix RST/Markdown false heading detection (#21685)
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/trst.nim39
-rw-r--r--tests/stdlib/trstgen.nim2
2 files changed, 40 insertions, 1 deletions
diff --git a/tests/stdlib/trst.nim b/tests/stdlib/trst.nim
index c32ed1762..c9024ded8 100644
--- a/tests/stdlib/trst.nim
+++ b/tests/stdlib/trst.nim
@@ -67,6 +67,45 @@ proc toAst(input: string,
       result = e.msg
 
 suite "RST parsing":
+  test "Standalone punctuation is not parsed as heading overlines":
+    check(dedent"""
+        Paragraph
+
+        !""".toAst ==
+      dedent"""
+        rnInner
+          rnParagraph
+            rnLeaf  'Paragraph'
+          rnParagraph
+            rnLeaf  '!'
+      """)
+
+    check(dedent"""
+        Paragraph1
+
+        ...
+
+        Paragraph2""".toAst ==
+      dedent"""
+        rnInner
+          rnParagraph
+            rnLeaf  'Paragraph1'
+          rnParagraph
+            rnLeaf  '...'
+          rnParagraph
+            rnLeaf  'Paragraph2'
+      """)
+
+    check(dedent"""
+        ---
+        Paragraph""".toAst ==
+      dedent"""
+        rnInner
+          rnLeaf  '---'
+          rnLeaf  ' '
+          rnLeaf  'Paragraph'
+      """)
+
   test "References are whitespace-neutral and case-insensitive":
     # refname is 'lexical-analysis', the same for all the 3 variants:
     check(dedent"""
diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim
index 8c07b35f0..dae4ea1cf 100644
--- a/tests/stdlib/trstgen.nim
+++ b/tests/stdlib/trstgen.nim
@@ -617,8 +617,8 @@ context2
 This is too short to be a transition:
 
 ---
-
 context2
+---
 """
     var error2 = new string
     let output2 = input2.toHtml(error=error2)