Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Render more of the markdown seen in readmes
A line of equals signs or dashes under a paragraph now makes a heading
of it, as on GitHub, instead of running into its text, and any other
rule ends the paragraph. Four spaces or a tab start a code block, and an
escaped pipe stays in its table cell. A link opening with two slashes
or backslashes in any mix leads to another site, so it renders as text
like the plain scheme relative one already did.
Diffstat (limited to 'tests/extensions/test-about-render.lua')
| -rw-r--r-- | tests/extensions/test-about-render.lua | 26 |
1 file changed, 26 insertions, 0 deletions
diff --git a/tests/extensions/test-about-render.lua b/tests/extensions/test-about-render.lua index a493720..0571796 100644 --- a/tests/extensions/test-about-render.lua +++ b/tests/extensions/test-about-render.lua @@ -257,6 +257,26 @@ render("README.md", string.rep("# a\n", 50000)) render("README.md", "| a | b |\n|---|---|\n| x" .. string.rep(" ", 40000) .. "y | z |") h.check("a long run of spaces is trimmed quickly", os.clock() - started < 10) +out = render("README.md", "Title\n=====\n\nBody") +h.contains("equals signs under a line make a heading", out, "<h1 id='title'>Title</h1><p>Body</p>") + +out = render("README.md", "Two\nlines\n---\nafter") +h.contains("dashes under a paragraph make a heading of it all", out, + "<h2 id='two-lines'>Two lines</h2><p>after</p>") + +out = render("README.md", "text\n***\nmore") +h.contains("a rule ends the paragraph above it", out, "<p>text</p><hr><p>more</p>") + +out = render("README.md", "Para\n\n code line\n\tnext <line>\n\nafter") +h.contains("an indented block renders as code", out, + "<p>Para</p><pre><code>code line\nnext <line>\n</code></pre><p>after</p>") + +out = render("README.md", "- item\n\n more about it") +h.excludes("an indented paragraph after a list stays prose", out, "<pre>") + +out = render("README.md", "[a](\\\\evil.example/x) [b](\\/evil.example/x)") +h.excludes("a scheme relative link spelt with backslashes renders no anchor", out, "<a ") + out = render("README.md", "| a | b |\n| --- | --- |\n| 1 | 2 |") h.contains("a pipe table renders its head", out, "<thead><tr><th>a</th><th>b</th></tr></thead>") h.contains("a pipe table renders its body", out, "<tbody><tr><td>1</td><td>2</td></tr></tbody>") @@ -267,6 +287,12 @@ h.contains("a table cuts a paragraph short", out, "<p>Pick one:</p><table><thead out = render("README.md", "a | b in prose") h.excludes("a pipe without a delimiter row stays prose", out, "<table") +out = render("README.md", "| a | b |\n|---|---|\n| x \\| y | `p \\| q` |") +h.contains("an escaped pipe stays in its cell", out, "<td>x | y</td><td><code>p | q</code></td>") + +out = render("README.md", "| a | b |\n|---|---|\n| x \\\\| y |") +h.contains("an escaped backslash still lets the pipe divide", out, "<td>x \\</td><td>y</td>") + out = render("README.md", "- first\n- second") h.contains("dashes render an unordered list", out, "<ul><li>first</li><li>second</li></ul>") |
