## ~xigoi/xidoc

0e50d655e1d074ebeb2cadf03dc602e306093f12 — Adam Blažek 3 months ago
```Tests for block formatting
```
```1 files changed, 65 insertions(+), 0 deletions(-)

M tests/test_documents.nim
```
`M tests/test_documents.nim => tests/test_documents.nim +65 -0`
```@@ 93,3 93,68 @@ suite "\"Inline formatting\" commands":

test "[unit]":
"The radius of the Earth is [unit 6378; km].".shouldRenderAs("The radius of the Earth is 6378 km.")
+
+suite "\"Inline formatting\" commands":
+
+  test "[block-quote]":
+    "[p The first rule in the Zen of Nim is:] [block-quote Copying bad design is not good design.]"
+    .shouldRenderAs("<p>The first rule in the Zen of Nim is:</p> <blockquote>Copying bad design is not good design.</blockquote>")
+
+  test "[checkboxes]":
+    "[checkboxes [v Kill the friend] [- Bury the body] [x Get caught by the police]]"
+    .shouldRenderAs("<ul class=\"xd-checkboxes\"><li class=\"xd-checkbox-checked\">Kill the friend</li> <li class=\"xd-checkbox-unchecked\">Bury the body</li> <li class=\"xd-checkbox-crossed\">Get caught by the police</li></ul>")
+
+  test "[code-block]":
+    """[code-block [raw<
+      const factorial = (n) => {
+        let result = 1n;
+        for (let i = 1; i <= n; i++) {
+          result *= BigInt(i);
+        }
+        return result;
+      }
+    ]]"""
+    .shouldRenderAs("""<pre><code>const factorial = (n) => {
+  let result = 1n;
+  for (let i = 1; i &lt;= n; i++) {
+    result *= BigInt(i);
+  }
+  return result;
+}
+</code></pre>""")
+
+  test "[figure]":
+    "[figure IMAGE]".shouldRenderAs("<figure>IMAGE</figure>")
+    "[figure IMAGE; CAPTION]".shouldRenderAs("<figure>IMAGE<figcaption>CAPTION</figcaption></figure>")
+
+  test "[link-image]":
+    "[link-image xidoc logo; logo.svg]".shouldRenderAs("<img src=\"logo.svg\" alt=\"xidoc logo\" />")
+    "[link-image xidoc logo; logo.svg; https://xidoc.nim.town/]".shouldRenderAs("<a href=\"https://xidoc.nim.town/\"><img src=\"logo.svg\" alt=\"xidoc logo\" /></a>")
+
+  test "[list]":
+    "Supported targets: [list HTML; LaTeX; Gemtext]"
+    .shouldRenderAs("Supported targets: <ul><li>HTML</li><li>LaTeX</li><li>Gemtext</li></ul>")
+
+  test "[ordered-list]":
+    "TOP 5 LIST OF SMALLEST POSITIVE INTEGERS: [ordered-list 1; 2; 3; 4; 5]"
+    .shouldRenderAs("TOP 5 LIST OF SMALLEST POSITIVE INTEGERS: <ol><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ol>")
+
+  test "[p]":
+    "[p PARAGRAPH]".shouldRenderAs("<p>PARAGRAPH</p>")
+
+  test "[section]":
+    "[section Are we going too deep?]".shouldRenderAs("<section>Are we going too deep?</section>")
+    "[section Inception; Are we going too deep?]".shouldRenderAs("<section><h2 class=\"xd-section-heading\">Inception</h2>Are we going too deep?</section>")
+    "[section [section Inception; Are we going too deep?]]".shouldRenderAs("<section><section><h3 class=\"xd-section-heading\">Inception</h3>Are we going too deep?</section></section>")
+
+  test "[spoiler]":
+    "[spoiler In the series The Simpsons, the surname of the main characters is; Simpson]"
+    .shouldRenderAs("<details class=\"xd-spoiler\"><summary>In the series The Simpsons, the surname of the main characters is</summary>Simpson</details>")
+
+  test "[table], [row], [header-row]":
+    "[table [header-row a; b; c][row d; e; f]]"
+    .shouldRenderAs("<table><tr><th>a</th><th>b</th><th>c</th></tr><tr><td>d</td><td>e</td><td>f</td></tr></table>")
+
+  test "[title]":
+    "[title TITLE]".shouldRenderAs("<h1>TITLE</h1>")
+    check renderXidoc("[title TITLE]").contains("<title>TITLE</title>")

```