Markdown and Mermaid to HTML5, and HTML5 to a paginated PDF, in MoonBit
.mmd / .md -> parse -> split -> HTML5 -> (browser) -> PDF| reference (Python / JS) | this package |
|---|---|
| build_final.py | src/mermaid + src/md |
| build_pdf.js | src/printpdf (the pagination maths) |
moon add riantr/moonbit_markdown # the latest release
moon add riantr/moonbit_markdown@0.1.3 # that release exactlymoon run . mmd2html <in.mmd> out.htmlpython ci/ci.py # CI PASS: 9/9 steps passed
python ci/ci.py --tiers browser,spec # the slow half, 4 more steps
moon check # 0 errors, 0 warnings
moon test # 105/105, failed: 0
python verify_pdf_moonbit.py # ALL PDF COMPARISON CHECKS PASSED
node verify_page.js moonbit_doubleML_state_diagram.html <in.mmd>
# ALL PAGE CHECKS PASSEDnode build_pdf.js # the reference pdf
moon run . mmd2html <in.mmd> moonbit_doubleML_state_diagram.html
moon run . mmd2pdf <in.mmd> moonbit_doubleML_state_diagram_moonbit.pdf
moon run . md2html md_with_diagram.md md_with_diagram.html| package | what it does | dependencies |
|---|---|---|
| src/text | character-level text helpers | none |
| src/md | Markdown parser and HTML5 renderer | src/text |
| src/mermaid | Mermaid scan parser and self-contained page builder | src/text |
| src/printpdf | the print layout: the split, the pagination maths, the page assembly | src/text, src/mermaid |
| src/mdcli | the command line tool | the pure packages; moonbitlang/core/async on native and wasm |
| target | the file and process layer |
|---|---|
| native | the file system and the process runtime of the toolchain, driven to completion from a synchronous caller |
| wasm | the same |
| js | Node's own fs and child_process |
| wasm-gc | the file system bridge of the wasm host |
moon run . mmd2html <in.mmd> <out.html> # a Mermaid scan to the page
moon run . md2html <in.md> <out.html> # a Markdown document to a page
moon run . print2pdf <in.html> <out.pdf> # a page to PDF, via headless Chrome
moon run . mmd2pdf <in.mmd> <out.pdf> # a scan to a paginated PDF
moon run . md2pdf <in.md> <out.pdf> # a document to a paginated PDF
moon run . mmd2measure <in.mmd> # the measured geometry, for checkingfigure 0 166.2 x 210.0 mm labels 6.0 pt
figure 2 342.9 x 594.0 mm labels 3.6 pt capped by --figure-page-max
figure 3 311.7 x 594.0 mm labels 4.6 pt capped by --figure-page-max
figure 4 344.6 x 594.0 mm labels 5.8 pt capped by --figure-page-max
figure 6 289.7 x 576.2 mm labels 6.0 pt
figure 7 148.0 x 371.0 mm labels 6.0 ptfigure 0 166.1 x 209.9 mm 6.17 pt
figure 2 342.9 x 594.1 mm 3.56 pt
figure 3 311.8 x 594.1 mm 4.55 pt
figure 4 344.7 x 576.1 mm 5.82 pt
figure 6 289.6 x 576.1 mm 6.00 pt
figure 7 148.2 x 371.1 mm 6.00 ptnode tools/commonmark_spec.js # render every example and compare
node tools/commonmark_spec.js --show Links 5 # the examples of one section| section | ||
|---|---|---|
| links | 81/90 | the cases where the text of a link holds an unfinished HTML tag |
| lists | 22/26 | a list whose item holds a nested list with a blank line inside it is called loose when the spec calls it tight |
| tabs | 9/11 | the tab stops inside a list item are counted in columns, not in tab stops |
| setext headings, link reference definitions | 26/27 each | one case each: a label that differs from its reference only in Greek capitals is not folded, because the case folding of the toolchain covers ASCII only |
moon test # the whole module
moon test src/md # one package
python ci/check_fmt.py # the sources are formatted the way `moon fmt` formats them
python ci/check_targets.py # every target builds, starts and passes its testsnode verify_page.js moonbit_doubleML_state_diagram.html <in.mmd>
node verify_md_page.js <a markdown page with a diagram>
python verify_pdf_moonbit.py| variable | what it names |
|---|---|
| CHROME | the Chrome or Edge binary to drive |
| MERMAID_JS | the mermaid.min.js runtime to inline |
| PUPPETEER_MODULE | the puppeteer module to load |
moon run . mmd2html <in.mmd> moonbit_doubleML_state_diagram.html
moon run . mmd2pdf <in.mmd> moonbit_doubleML_state_diagram_moonbit.pdf
moon run . md2html md_with_diagram.md md_with_diagram.html
moon run . md2pdf md_with_diagram.md md_with_diagram.pdf
node build_pdf.js # the REFERENCE pdf| document | files | notice states | notes | findings |
|---|---|---|---|---|
| moonbit_doubleML_state_diagram.html | 221 | 2147 | 2371 | 1 |
python ci/ci.py --self-check # 29/29: the engine's own accounting
python ci/ci.py # env + build + gates (fast, portable)
python ci/ci.py --tiers env,build,gates,browser,spec --check-release
# would a tag be allowed? changes nothing
python ci/ci.py --tiers env,build,gates,browser,spec --tag --push| tier | what it runs | needs |
|---|---|---|
| env | moon, node, python versions | nothing |
| build | moon check, moon test, ci/check_fmt.py: the source formatting check, the four pure packages on all four targets, ci/check_targets.py: every target builds, starts and passes its tests | nothing |
| gates | ci/check_artifacts.py: the structure of the generated documents | the generated documents |
| browser | verify_page.js, verify_md_page.js, verify_pdf_moonbit.py | Chrome, the generated documents |
| spec | tools/commonmark_spec.js, against the floor this README states | the spec download |
| remote | what it carries |
|---|---|
| gitee | the working remote: the commits and the tags |
| GitHub | the release remote: the tag push starts the publish |
Install
Download zipMarkdown and Mermaid to HTML5, and HTML5 to a paginated PDF, in MoonBit