summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorMiran <narimiran@disroot.org>2020-11-10 09:41:26 +0100
committerGitHub <noreply@github.com>2020-11-10 09:41:26 +0100
commitee78d7610853f4866c9b3d1e81d523b7ef339da0 (patch)
tree48fb70888df2e0dde545e9b40a25d39ad302d1a0 /tests
parentd8e7caf5dd4ab70b7429896c1587cde992e7855a (diff)
downloadNim-ee78d7610853f4866c9b3d1e81d523b7ef339da0.tar.gz
rst: add support for markdown tables (#15854)
* rst: add support for markdown tables

* change template into proc

* don't create unnecessary `seq[string]`
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/trstgen.nim24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim
index 8fdbf3911..d35bc5821 100644
--- a/tests/stdlib/trstgen.nim
+++ b/tests/stdlib/trstgen.nim
@@ -153,3 +153,27 @@ suite "YAML syntax highlighting":
     assert a == """(( <a class="reference external" href="https://nim-lang.org/">Nim</a> ))"""
     assert b == """((<a class="reference external" href="https://nim-lang.org/">Nim</a>))"""
     assert c == """[<a class="reference external" href="https://nim-lang.org/">Nim</a>]"""
+
+  test "Markdown tables":
+    let input1 = """
+| A1 header    | A2 \| not fooled
+| :---         | ----:       |
+| C1           | C2 **bold** | ignored |
+| D1 `code \|` | D2          | also ignored
+| E1 \| text   |
+|              | F2 without pipe
+not in table"""
+    let output1 = rstToHtml(input1, {roSupportMarkdown}, defaultConfig())
+    assert output1 == """<table border="1" class="docutils"><tr><th>A1 header</th><th>A2 | not fooled</th></tr>
+<tr><td>C1</td><td>C2 <strong>bold</strong></td></tr>
+<tr><td>D1 <tt class="docutils literal"><span class="pre">code |</span></tt></td><td>D2</td></tr>
+<tr><td>E1 | text</td><td></td></tr>
+<tr><td></td><td>F2 without pipe</td></tr>
+</table><p>not in table</p>
+"""
+    let input2 = """
+| A1 header | A2 |
+| --- | --- |"""
+    let output2 = rstToHtml(input2, {roSupportMarkdown}, defaultConfig())
+    assert output2 == """<table border="1" class="docutils"><tr><th>A1 header</th><th>A2</th></tr>
+</table>"""