~subsetpark/bagatto

4562bc9b5b23370c740e27ce6c5b96d79329adc6 — Zach Smith 3 months ago 19aea03 13/moondown-nesting
Replace moondown with markable

Fixes #13.
4 files changed, 38 insertions(+), 7 deletions(-)

M bagatto.janet
M lockfile.jdn
M project.janet
A test/markdown.janet
M bagatto.janet => bagatto.janet +4 -3
@@ 1,6 1,6 @@
(import sh)
(import temple)
(import moondown)
(import markable)
(import path)
(import jdn)
(import json)


@@ 438,8 438,9 @@

(defn markdown->html
  "Render a markdown string into HTML."
  [md]
  (moondown/render (string md)))
  [md &opt opts]
  (default opts [:footnotes :smart])
  (markable/markdown->html (string md) [:footnotes]))

(defn mmarkdown->html
  ```

M lockfile.jdn => lockfile.jdn +3 -2
@@ 1,9 1,10 @@
@[{:sha "2268b81004bb9b58e8b263584c86219dab8180ac" :repo "https://github.com/andrewchambers/janet-jdn.git"}
  {:sha "30acacff4f3b1466d92440264f93dbdd2e8ab5ed" :repo "https://github.com/janet-lang/argparse.git"}
  {:sha "b06c5dc089304e6a8a9685e02721f8175e5eeb90" :repo "https://github.com/janet-lang/argparse.git"}
  {:sha "70ae525ad8ab0bf08ccb42e9544ac2bd2103df35" :repo "https://github.com/andrewchambers/janet-posix-spawn.git"}
  {:sha "ed7e83e8779e2a54e23bbbcc75366ade2dd5372a" :repo "https://git.sr.ht/~bakpakin/temple"}
  {:sha "ca257dd40159cf25bc49869386208df630b88336" :repo "https://github.com/pyrmont/testament"}
  {:sha "80785d8467e950e8b8c44ea7d0da3f6e1684b952" :repo "https://github.com/joy-framework/tester"}
  {:sha "b6dd2f3dcfebd26b027234a84029ee099b83b1f0" :repo "https://github.com/janet-lang/path.git"}
  {:sha "61437d96b5df6eb7e524f88847e7d7521201662d" :repo "https://github.com/janet-lang/json.git"}
  {:sha "4226a4cae548fde38358aa1fdb6d6a90bf5fe175" :repo "https://github.com/andrewchambers/janet-sh.git"}
  {:sha "3bd3376a3eb838201738a6c8945069b72591f7fa" :repo "https://github.com/joy-framework/moondown"}]
  {:sha "64db559d6be781a05adee4b42be6ad7a4d575380" :repo "https://github.com/pyrmont/markable"}]

M project.janet => project.janet +3 -2
@@ 3,11 3,12 @@
  :description "an extensible, transparent static site generator"
  :dependencies ["https://github.com/andrewchambers/janet-sh.git"
                 "https://git.sr.ht/~bakpakin/temple"
                 {:repo "https://github.com/joy-framework/moondown" :tag "0.2.0"}
                 "https://github.com/pyrmont/markable"
                 "https://github.com/janet-lang/path.git"
                 "https://github.com/andrewchambers/janet-jdn.git"
                 "https://github.com/janet-lang/json.git"
                 "https://github.com/janet-lang/argparse.git"])
                 "https://github.com/janet-lang/argparse.git"
                 "https://github.com/pyrmont/testament"])

(declare-executable
  :name "bag"

A test/markdown.janet => test/markdown.janet +28 -0
@@ 0,0 1,28 @@
(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
                 ```
        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"
        rendered (bagatto/markdown->html footnote)]
    (is (= expected rendered))))

(run-tests!)