tvl-depot/web/panettone/test/inline-markdown_test.lisp
sterni 0d24efcdc9 fix(web/panettone): make (who:html-mode) stick
(who:html-mode) needs to be set at macro expansion time to properly take
effect which wasn't the case before, but is ensured now by
:compile-toplevel. :load-toplevel ensures that who inside the repl will
behave the same.

Since the :html5 behavior is now actually used, we need to adjust some
of the test cases to account for the different :html5 escaping mode.

Change-Id: I4dfe1d2db38da6a2486fde86596f7e5f50ed8b9f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4885
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-01-13 23:19:31 +00:00

54 lines
1.8 KiB
Common Lisp

(in-package :panettone.tests)
(declaim (optimize (safety 3)))
(defmacro inline-markdown-unit-test (name input expected)
`(test ,name
(is (equal
,expected
(with-output-to-string (*standard-output*)
(render-inline-markdown ,input))))))
(inline-markdown-unit-test
inline-markdown-typical-test
"hello *world*, here is ~~no~~ `code`!"
"hello <em>world</em>, here is <del>no</del> <code>code</code>!")
(inline-markdown-unit-test
inline-markdown-two-emphasize-types-test
"*stress* *this*"
"<em>stress</em> <em>this</em>")
(inline-markdown-unit-test
inline-markdown-html-escaping-test
"<tag>öäü"
"&lt;tag&gt;&#xF6;&#xE4;&#xFC;")
(inline-markdown-unit-test
inline-markdown-nesting-test
"`inside code *anything* goes`, but also ~~*here*~~"
"<code>inside code *anything* goes</code>, but also <del>*here*</del>")
(inline-markdown-unit-test
inline-markdown-escaping-test
"A backslash \\\\ shows: \\*, \\` and \\~~"
"A backslash \\ shows: *, ` and ~~")
(inline-markdown-unit-test
inline-markdown-nested-escaping-test
"`prevent \\`code\\` from ending, but never stand alone \\\\`"
"<code>prevent `code` from ending, but never stand alone \\</code>")
(inline-markdown-unit-test
inline-markdown-escape-normal-tokens-test
"\\Normal tokens \\escaped?"
"\\Normal tokens \\escaped?")
(inline-markdown-unit-test
inline-markdown-no-unclosed-tags-test
"A tag, once opened, *must be closed"
"A tag, once opened, <em>must be closed</em>")
(inline-markdown-unit-test
inline-markdown-unicode-safe
"Does Unicode 👨‍👨‍👧‍👦 break \\👩🏾‍🦰 tokenization?"
"Does Unicode &#x1F468;&#x200D;&#x1F468;&#x200D;&#x1F467;&#x200D;&#x1F466; break \\&#x1F469;&#x1F3FE;&#x200D;&#x1F9B0; tokenization?")