~subsetpark/bagatto

ref: b6442147cba8be445138834953e3ee4c434c8e08 bagatto/test/markdown.janet -rw-r--r-- 1.8 KiB
b6442147 — Zach Smith Include alternate footnotes output 1 year, 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(import testament :prefix "" :exit true)
(import /bagatto)

(setdyn :executable-blacklist {})

(deftest render-nested-md
  (let [nesting ```
                * [one](https://janetdocs.com)
                    * [two](https://janetdocs.com)
                        * [three](https://janetdocs.com)
                            * [four](https://janetdocs.com)
                                * [five](https://janetdocs.com)
                ```
        expected "<ul>\n<li><a href=\"https://janetdocs.com\">one</a>\n<ul>\n<li><a href=\"https://janetdocs.com\">two</a>\n<ul>\n<li><a href=\"https://janetdocs.com\">three</a>\n<ul>\n<li><a href=\"https://janetdocs.com\">four</a>\n<ul>\n<li><a href=\"https://janetdocs.com\">five</a></li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n</li>\n</ul>\n"
        rendered (bagatto/markdown->html nesting)]
    (is (= expected rendered))))

(deftest render-footnote
  (let [footnote ```
                 foo[^bar]

                 [^bar]: baz
                 ```
        # Different builds of markable produce different footnote outputs, but both are valid.
        expected "<p>foo<sup class=\"footnote-ref\"><a href=\"#fn1\" id=\"fnref1\">1</a></sup></p>\n<section class=\"footnotes\">\n<ol>\n<li id=\"fn1\">\n<p>baz <a href=\"#fnref1\" class=\"footnote-backref\">\xE2\x86\xA9</a></p>\n</li>\n</ol>\n</section>\n"
        alternate "<p>foo<sup class=\"footnote-ref\"><a href=\"#fn-bar\" id=\"fnref-bar\" data-footnote-ref>1</a></sup></p>\n<section class=\"footnotes\" data-footnotes>\n<ol>\n<li id=\"fn-bar\">\n<p>baz <a href=\"#fnref-bar\" class=\"footnote-backref\" data-footnote-backref aria-label=\"Back to content\">\xE2\x86\xA9</a></p>\n</li>\n</ol>\n</section>\n"
        rendered (bagatto/markdown->html footnote)]
    (is (or (= alternate rendered) (= expected rendered)))))

(run-tests!)