MoonMark is a deterministic Markdown-to-HTML renderer written in MoonBit. It targets README-style documents, generated reports, and small documentation fragments that need predictable output and safe HTML escaping.
This project is prepared for the MoonBit open-source ecosystem contribution competition.
Features
Block rendering for headings, paragraphs, unordered lists, block quotes, and fenced code blocks.
Inline rendering for emphasis, strong text, inline code, and links.
HTML escaping for text, code, and link attributes.
Heading extraction API for table-of-contents generation.
A small runnable CLI demo under cmd/main.
Snapshot-style tests that cover the public API.
Quick Start
Install the MoonBit toolchain, then run:
moon check
moon test
moon run cmd/main
Use the library from another package:
let html = @moonmark.render("# Title\n\nA **safe** renderer.")
println(html)
MoonMark intentionally implements a compact subset:
Markdown
HTML
# Heading through ###### Heading
<h1> through <h6>
Plain text separated by blank lines
<p>
- item, * item, + item
<ul><li>
> quote
<blockquote>
Triple-backtick fences
<pre><code>
`code`
<code>
*em*
<em>
**strong**
<strong>
[label](url)
<a href="url">label</a>
Non-goals for the current release include full CommonMark compatibility, nested block parsing, ordered lists, tables, and raw HTML passthrough. These are tracked as future extensions so the first release remains easy to audit and verify.
docs/submission-checklist.md: final submission checklist.
Competition Scope
The current repository is a complete first milestone: parser, renderer, escaping, heading extraction, tests, CLI demo, CI, README, license, and proposal draft. To better match the competition’s suggested 4k-10k LOC project scale, continue with the planned extensions in docs/submission-checklist.md, especially ordered lists, tables, slug generation, more examples, and Mooncakes publication.
Quality Gates
The repository is expected to pass:
moon check
moon test
GitHub Actions runs the same checks on push and pull request.
MoonMark
MoonMark is a deterministic Markdown-to-HTML renderer written in MoonBit. It targets README-style documents, generated reports, and small documentation fragments that need predictable output and safe HTML escaping.
This project is prepared for the MoonBit open-source ecosystem contribution competition.
Features
cmd/main.Quick Start
Install the MoonBit toolchain, then run:
Use the library from another package:
Output:
Supported Markdown
MoonMark intentionally implements a compact subset:
# Headingthrough###### Heading<h1>through<h6><p>- item,* item,+ item<ul><li>> quote<blockquote><pre><code>`code`<code>*em*<em>**strong**<strong>[label](url)<a href="url">label</a>Non-goals for the current release include full CommonMark compatibility, nested block parsing, ordered lists, tables, and raw HTML passthrough. These are tracked as future extensions so the first release remains easy to audit and verify.
API
Heading::level()andHeading::text()expose the parsed heading metadata.Examples
Project Structure
moonmark.mbt: library implementation.moonmark_test.mbt: public API tests.cmd/main: runnable demo program.docs/project-proposal.md: one-page competition proposal draft.docs/submission-checklist.md: final submission checklist.Competition Scope
The current repository is a complete first milestone: parser, renderer, escaping, heading extraction, tests, CLI demo, CI, README, license, and proposal draft. To better match the competition’s suggested 4k-10k LOC project scale, continue with the planned extensions in
docs/submission-checklist.md, especially ordered lists, tables, slug generation, more examples, and Mooncakes publication.Quality Gates
The repository is expected to pass:
GitHub Actions runs the same checks on push and pull request.
License
Apache-2.0.