summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndrey Makarov <ph.makarov@gmail.com>2020-12-27 13:16:12 +0300
committerGitHub <noreply@github.com>2020-12-27 11:16:12 +0100
commit2bdc479622c465e570fdb87df112dd56ddc9030f (patch)
tree5b3f0abd04368714839bb4d77ff3a470361ff7e0 /tests
parent626c2bc6589101bd1b0231a2608e32b51f73abba (diff)
downloadNim-2bdc479622c465e570fdb87df112dd56ddc9030f.tar.gz
RST: implement admonitions (#16438)
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/trstgen.nim49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim
index 85a96056a..3283af8c6 100644
--- a/tests/stdlib/trstgen.nim
+++ b/tests/stdlib/trstgen.nim
@@ -535,6 +535,55 @@ Test1
     assert count(output1, "<ul ") == 1
     assert count(output1, "</ul>") == 1
 
+  test "RST admonitions":
+    # check that all admonitions are implemented
+    let input0 = dedent """
+      .. admonition:: endOf admonition
+      .. attention:: endOf attention
+      .. caution:: endOf caution
+      .. danger:: endOf danger
+      .. error:: endOf error
+      .. hint:: endOf hint
+      .. important:: endOf important
+      .. note:: endOf note
+      .. tip:: endOf tip
+      .. warning:: endOf warning
+    """
+    let output0 = rstToHtml(input0, {roSupportMarkdown}, defaultConfig())
+    for a in ["admonition", "attention", "caution", "danger", "error", "hint",
+        "important", "note", "tip", "warning" ]:
+      assert "endOf " & a & "</div>" in output0
+
+    # Test that admonition does not swallow up the next paragraph.
+    let input1 = dedent """
+      .. error:: endOfError
+
+      Test paragraph.
+    """
+    let output1 = rstToHtml(input1, {roSupportMarkdown}, defaultConfig())
+    assert "endOfError</div>" in output1
+    assert "<p>Test paragraph. </p>" in output1
+    assert "class=\"admonition admonition-error\"" in output1
+
+    # Test that second line is parsed as continuation of the first line.
+    let input2 = dedent """
+      .. error:: endOfError
+        Test2p.
+
+      Test paragraph.
+    """
+    let output2 = rstToHtml(input2, {roSupportMarkdown}, defaultConfig())
+    assert "endOfError Test2p.</div>" in output2
+    assert "<p>Test paragraph. </p>" in output2
+    assert "class=\"admonition admonition-error\"" in output2
+
+    let input3 = dedent """
+      .. note:: endOfNote
+    """
+    let output3 = rstToHtml(input3, {roSupportMarkdown}, defaultConfig())
+    assert "endOfNote</div>" in output3
+    assert "class=\"admonition admonition-info\"" in output3
+
 suite "RST/Code highlight":
   test "Basic Python code highlight":
     let pythonCode = """