~xigoi/xidoc

58ed14ca22b7e0868b1750a0466831bb76cf7601 — Adam Blažek 3 months ago 4a77e2c
Test for inline formatting
2 files changed, 38 insertions(+), 2 deletions(-)

M edit
M tests/test_documents.nim
M edit => edit +1 -1
@@ 1,3 1,3 @@
#!/usr/bin/bash
shopt -s globstar
nvim xidoc.nimble src/**/*.nim docs/*.xd
nvim xidoc.nimble src/**/*.nim docs/*.xd tests/*.nim

M tests/test_documents.nim => tests/test_documents.nim +37 -1
@@ 35,7 35,8 @@ suite "\"Basic constructs\" commands":
    "[bf [space]x[space]]".shouldRenderAs("<b> x </b>")

  test "[raw]":
    "[raw [I can use [as many brackets [as I want]], but [they] still have to [[be balanced]]].]".shouldRenderAs("[I can use [as many brackets [as I want]], but [they] still have to [[be balanced]]].")
    "[raw [I can use [as many brackets [as I want]], but [they] still have to [[be balanced]]].]"
    .shouldRenderAs("[I can use [as many brackets [as I want]], but [they] still have to [[be balanced]]].")

  test "[raw<]":
    """[raw<


@@ 57,3 58,38 @@ suite "\"Basic constructs\" commands":

  test "[add-to-head]":
    check "[add-to-head BOOM]".renderXidoc.contains("BOOM</head>")

suite "\"Inline formatting\" commands":

  test "[bf]":
    "xidoc is [bf awesome]!".shouldRenderAs("xidoc is <b>awesome</b>!")

  test "[code]":
    "[code [raw print(f\"The answer to the universe and stuff is {6 * 7}.\")]]"
    .shouldRenderAs("<code>print(f&quot;The answer to the universe and stuff is {6 * 7}.&quot;)</code>")
    "[code python; [raw print(f\"The answer to the universe and stuff is {6 * 7}.\")]]"
    .shouldRenderAs("<code class=\"language-python\"><span class=\"token keyword\">print</span><span class=\"token punctuation\">(</span><span class=\"token string-interpolation\"><span class=\"token string\">f\"The answer to the universe and stuff is </span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token number\">6</span> <span class=\"token operator\">*</span> <span class=\"token number\">7</span><span class=\"token punctuation\">}</span></span><span class=\"token string\">.\"</span></span><span class=\"token punctuation\">)</span></code>")

  test "[color]":
    "You can use [color red; names] or [color #00f; codes]!".shouldRenderAs("You can use <span style=\"color:red\">names</span> or <span style=\"color:#00f\">codes</span>!")

  test "[it]":
    "xidoc is [it fantastic]!".shouldRenderAs("xidoc is <i>fantastic</i>!")

  test "[lang]":
    "[\" Hello!] [lang czech; [\" Ahoj!]]".shouldRenderAs("“Hello!” „Ahoj!“")

  test "[link]":
    "[link xidoc; http://xidoc.nim.town/] is made in [link Nim; https://nim-lang.org/]."
    .shouldRenderAs("<a href=\"http://xidoc.nim.town/\">xidoc</a> is made in <a href=\"https://nim-lang.org/\">Nim</a>.")

  test "[ms]":
    "In HTML, this will produce [ms <code>]. In LaTeX, this will produce [ms \\texttt]."
    .shouldRenderAs("In HTML, this will produce <code>&lt;code></code>. In LaTeX, this will produce <code>\\texttt</code>.")

  test "[term]":
    "A [term group] is a monoid where every element has an inverse."
    .shouldRenderAs("A <dfn>group</dfn> is a monoid where every element has an inverse.")

  test "[unit]":
    "The radius of the Earth is [unit 6378; km].".shouldRenderAs("The radius of the Earth is 6378 km.")