Add frontmatter, markdown, path, xml, rss, and web packages

Sync local packages into the registry repo and update index.json
and README.md to include all 9 packages.
This commit is contained in:
2026-02-24 21:04:20 -05:00
parent c5a2276f6e
commit cbb66fbb73
42 changed files with 3844 additions and 0 deletions

View File

@@ -0,0 +1,112 @@
import lib
// Snapshot tests: compare full markdown→HTML conversion against golden output
// Snapshot: simple document with heading and paragraph
fn test_snapshot_heading_and_para(): Unit with {Test} = {
let md = "# Hello World\n\nThis is a paragraph."
let expected = "<h1>Hello World</h1>\n<p>This is a paragraph.</p>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: heading + paragraph")
}
// Snapshot: all heading levels
fn test_snapshot_all_headings(): Unit with {Test} = {
Test.assertEqualMsg("<h1>H1</h1>\n", lib.toHtml("# H1"), "snap: h1")
Test.assertEqualMsg("<h2>H2</h2>\n", lib.toHtml("## H2"), "snap: h2")
Test.assertEqualMsg("<h3>H3</h3>\n", lib.toHtml("### H3"), "snap: h3")
Test.assertEqualMsg("<h4>H4</h4>\n", lib.toHtml("#### H4"), "snap: h4")
}
// Snapshot: inline formatting combinations
fn test_snapshot_inline_combos(): Unit with {Test} = {
Test.assertEqualMsg("<strong>bold</strong>", lib.inlineToHtml("**bold**"), "snap: bold")
Test.assertEqualMsg("<em>italic</em>", lib.inlineToHtml("*italic*"), "snap: italic")
Test.assertEqualMsg("<code>code</code>", lib.inlineToHtml("`code`"), "snap: code")
Test.assertEqualMsg("<del>strike</del>", lib.inlineToHtml("~~strike~~"), "snap: strike")
Test.assertEqualMsg("<a href=\"/\">link</a>", lib.inlineToHtml("[link](/)"), "snap: link")
Test.assertEqualMsg("<img src=\"i.png\" alt=\"a\">", lib.inlineToHtml("![a](i.png)"), "snap: image")
}
// Snapshot: unordered list
fn test_snapshot_unordered_list(): Unit with {Test} = {
let md = "- Alpha\n- Beta\n- Gamma"
let expected = "<ul>\n<li>Alpha</li>\n<li>Beta</li>\n<li>Gamma</li>\n</ul>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: unordered list")
}
// Snapshot: ordered list
fn test_snapshot_ordered_list(): Unit with {Test} = {
let md = "1. First\n2. Second\n3. Third"
let expected = "<ol>\n<li>First</li>\n<li>Second</li>\n<li>Third</li>\n</ol>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: ordered list")
}
// Snapshot: code block with language
fn test_snapshot_code_block(): Unit with {Test} = {
let md = "```rust\nlet x = 1;\nlet y = 2;\n```"
let expected = "<pre><code class=\"language-rust\">let x = 1;\nlet y = 2;\n</code></pre>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: code block with rust lang")
}
// Snapshot: code block without language
fn test_snapshot_code_block_no_lang(): Unit with {Test} = {
let md = "```\nplain code\n```"
let expected = "<pre><code>plain code\n</code></pre>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: code block no lang")
}
// Snapshot: blockquote
fn test_snapshot_blockquote(): Unit with {Test} = {
let md = "> This is quoted text"
let expected = "<blockquote>\n<p>This is quoted text</p>\n</blockquote>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: blockquote")
}
// Snapshot: horizontal rules
fn test_snapshot_horizontal_rules(): Unit with {Test} = {
Test.assertEqualMsg("<hr>\n", lib.toHtml("---"), "snap: hr dashes")
Test.assertEqualMsg("<hr>\n", lib.toHtml("***"), "snap: hr asterisks")
Test.assertEqualMsg("<hr>\n", lib.toHtml("___"), "snap: hr underscores")
}
// Snapshot: HTML passthrough
fn test_snapshot_html_passthrough(): Unit with {Test} = {
Test.assertEqualMsg("<div class=\"box\">content</div>\n", lib.toHtml("<div class=\"box\">content</div>"), "snap: div passthrough")
Test.assertEqualMsg("<video src=\"v.mp4\"></video>\n", lib.toHtml("<video src=\"v.mp4\"></video>"), "snap: video passthrough")
}
// Snapshot: heading with inline formatting inside list
fn test_snapshot_list_with_headings(): Unit with {Test} = {
let md = "- ### Chapter 1\n- ### Chapter 2"
let expected = "<ul>\n<li><h3>Chapter 1</h3></li>\n<li><h3>Chapter 2</h3></li>\n</ul>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: list with headings")
}
// Snapshot: complete blog post conversion
fn test_snapshot_blog_post(): Unit with {Test} = {
let md = "# My Post\n\nIntro paragraph with **bold** and *italic*.\n\n## Code Example\n\n```js\nconsole.log(\"hi\");\n```\n\n- Item one\n- Item two\n\n> A quote\n\n---\n\nThe end."
let html = lib.toHtml(md)
Test.assert(String.startsWith(html, "<h1>My Post</h1>"), "snap: blog starts with h1")
Test.assert(String.contains(html, "<strong>bold</strong>"), "snap: blog has bold")
Test.assert(String.contains(html, "<em>italic</em>"), "snap: blog has italic")
Test.assert(String.contains(html, "<h2>Code Example</h2>"), "snap: blog has h2")
Test.assert(String.contains(html, "language-js"), "snap: blog has js code block")
Test.assert(String.contains(html, "<li>Item one</li>"), "snap: blog has list item")
Test.assert(String.contains(html, "<blockquote>"), "snap: blog has blockquote")
Test.assert(String.contains(html, "<hr>"), "snap: blog has hr")
Test.assert(String.contains(html, "The end."), "snap: blog has closing")
}
// Snapshot: inline code with HTML entities
fn test_snapshot_code_html_entities(): Unit with {Test} = {
let result = lib.inlineToHtml("Use `<div>` and `&amp;` in HTML")
let expected = "Use <code>&lt;div&gt;</code> and <code>&amp;amp;</code> in HTML"
Test.assertEqualMsg(expected, result, "snap: code with HTML entities")
}
// Snapshot: multiple paragraphs
fn test_snapshot_multiple_paragraphs(): Unit with {Test} = {
let md = "First.\n\nSecond.\n\nThird."
let expected = "<p>First.</p>\n<p>Second.</p>\n<p>Third.</p>\n"
Test.assertEqualMsg(expected, lib.toHtml(md), "snap: three paragraphs")
}