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,160 @@
import lib
// --- escapeHtml ---
fn test_escape_empty(): Unit with {Test} =
Test.assertEqualMsg("", lib.escapeHtml(""), "escape empty string")
fn test_escape_no_special(): Unit with {Test} =
Test.assertEqualMsg("hello world", lib.escapeHtml("hello world"), "no special chars unchanged")
fn test_escape_ampersand(): Unit with {Test} =
Test.assertEqualMsg("a & b", lib.escapeHtml("a & b"), "escape ampersand")
fn test_escape_less_than(): Unit with {Test} =
Test.assertEqualMsg("&lt;div&gt;", lib.escapeHtml("<div>"), "escape angle brackets")
fn test_escape_all_three(): Unit with {Test} =
Test.assertEqualMsg("&lt;a&gt; &amp; &lt;b&gt;", lib.escapeHtml("<a> & <b>"), "escape all three")
// --- inline: bold ---
fn test_bold(): Unit with {Test} =
Test.assertEqualMsg("<strong>bold</strong>", lib.inlineToHtml("**bold**"), "bold text")
fn test_bold_in_sentence(): Unit with {Test} =
Test.assertEqualMsg("a <strong>bold</strong> b", lib.inlineToHtml("a **bold** b"), "bold in sentence")
fn test_bold_unclosed(): Unit with {Test} =
Test.assertEqualMsg("**unclosed", lib.inlineToHtml("**unclosed"), "unclosed bold")
// --- inline: italic ---
fn test_italic_asterisk(): Unit with {Test} =
Test.assertEqualMsg("<em>italic</em>", lib.inlineToHtml("*italic*"), "italic with asterisk")
fn test_italic_underscore(): Unit with {Test} =
Test.assertEqualMsg("<em>italic</em>", lib.inlineToHtml("_italic_"), "italic with underscore")
fn test_italic_unclosed(): Unit with {Test} =
Test.assertEqualMsg("*unclosed", lib.inlineToHtml("*unclosed"), "unclosed italic")
// --- inline: code ---
fn test_inline_code(): Unit with {Test} =
Test.assertEqualMsg("<code>code</code>", lib.inlineToHtml("`code`"), "inline code")
fn test_inline_code_with_html(): Unit with {Test} =
Test.assertEqualMsg("<code>&lt;div&gt;</code>", lib.inlineToHtml("`<div>`"), "code escapes HTML")
fn test_inline_code_unclosed(): Unit with {Test} =
Test.assertEqualMsg("`unclosed", lib.inlineToHtml("`unclosed"), "unclosed backtick")
// --- inline: strikethrough ---
fn test_strikethrough(): Unit with {Test} =
Test.assertEqualMsg("<del>strike</del>", lib.inlineToHtml("~~strike~~"), "strikethrough")
fn test_strikethrough_unclosed(): Unit with {Test} =
Test.assertEqualMsg("~~unclosed", lib.inlineToHtml("~~unclosed"), "unclosed strikethrough")
// --- inline: links ---
fn test_link(): Unit with {Test} =
Test.assertEqualMsg("<a href=\"/page\">text</a>", lib.inlineToHtml("[text](/page)"), "basic link")
fn test_link_with_formatting(): Unit with {Test} =
Test.assertEqualMsg("<strong><a href=\"/\">bold link</a></strong>", lib.inlineToHtml("**[bold link](/)**"), "bold link")
fn test_link_empty_text(): Unit with {Test} =
Test.assertEqualMsg("<a href=\"/page\"></a>", lib.inlineToHtml("[](/page)"), "link with empty text")
fn test_link_unclosed(): Unit with {Test} =
Test.assertEqualMsg("[unclosed", lib.inlineToHtml("[unclosed"), "unclosed bracket")
// --- inline: images ---
fn test_image(): Unit with {Test} =
Test.assertEqualMsg("<img src=\"img.png\" alt=\"alt text\">", lib.inlineToHtml("![alt text](img.png)"), "basic image")
fn test_image_empty_alt(): Unit with {Test} =
Test.assertEqualMsg("<img src=\"photo.jpg\" alt=\"\">", lib.inlineToHtml("![](photo.jpg)"), "image with empty alt")
// --- inline: plain text ---
fn test_plain_text(): Unit with {Test} =
Test.assertEqualMsg("hello world", lib.inlineToHtml("hello world"), "plain text unchanged")
fn test_empty_inline(): Unit with {Test} =
Test.assertEqualMsg("", lib.inlineToHtml(""), "empty input")
// --- block: headings ---
fn test_h1(): Unit with {Test} =
Test.assertEqualMsg("<h1>Hello</h1>\n", lib.toHtml("# Hello"), "h1")
fn test_h2(): Unit with {Test} =
Test.assertEqualMsg("<h2>World</h2>\n", lib.toHtml("## World"), "h2")
fn test_h3(): Unit with {Test} =
Test.assertEqualMsg("<h3>Sub</h3>\n", lib.toHtml("### Sub"), "h3")
fn test_h4(): Unit with {Test} =
Test.assertEqualMsg("<h4>Deep</h4>\n", lib.toHtml("#### Deep"), "h4")
fn test_heading_with_inline(): Unit with {Test} =
Test.assertEqualMsg("<h1><strong>Bold</strong> heading</h1>\n", lib.toHtml("# **Bold** heading"), "heading with inline formatting")
// --- block: paragraphs ---
fn test_single_paragraph(): Unit with {Test} =
Test.assertEqualMsg("<p>hello world</p>\n", lib.toHtml("hello world"), "single paragraph")
fn test_empty_input(): Unit with {Test} =
Test.assertEqualMsg("", lib.toHtml(""), "empty input produces empty output")
// --- block: code blocks ---
fn test_code_block(): Unit with {Test} =
Test.assertEqualMsg("<pre><code>hello\n</code></pre>\n", lib.toHtml("```\nhello\n```"), "code block")
fn test_code_block_with_lang(): Unit with {Test} =
Test.assertEqualMsg("<pre><code class=\"language-js\">let x = 1;\n</code></pre>\n", lib.toHtml("```js\nlet x = 1;\n```"), "code block with language")
fn test_code_block_escapes_html(): Unit with {Test} =
Test.assertEqualMsg("<pre><code>&lt;div&gt;\n</code></pre>\n", lib.toHtml("```\n<div>\n```"), "code block escapes HTML")
// --- block: lists ---
fn test_unordered_list(): Unit with {Test} =
Test.assertEqualMsg("<ul>\n<li>one</li>\n<li>two</li>\n</ul>\n", lib.toHtml("- one\n- two"), "unordered list")
fn test_ordered_list(): Unit with {Test} =
Test.assertEqualMsg("<ol>\n<li>first</li>\n<li>second</li>\n</ol>\n", lib.toHtml("1. first\n2. second"), "ordered list")
fn test_single_item_list(): Unit with {Test} =
Test.assertEqualMsg("<ul>\n<li>only</li>\n</ul>\n", lib.toHtml("- only"), "single item list")
// --- block: blockquotes ---
fn test_blockquote(): Unit with {Test} =
Test.assertEqualMsg("<blockquote>\n<p>quoted</p>\n</blockquote>\n", lib.toHtml("> quoted"), "blockquote")
// --- block: horizontal rules ---
fn test_hr_dashes(): Unit with {Test} =
Test.assertEqualMsg("<hr>\n", lib.toHtml("---"), "hr with dashes")
fn test_hr_asterisks(): Unit with {Test} =
Test.assertEqualMsg("<hr>\n", lib.toHtml("***"), "hr with asterisks")
fn test_hr_underscores(): Unit with {Test} =
Test.assertEqualMsg("<hr>\n", lib.toHtml("___"), "hr with underscores")
// --- block: HTML passthrough ---
fn test_html_passthrough(): Unit with {Test} =
Test.assertEqualMsg("<div class=\"foo\">bar</div>\n", lib.toHtml("<div class=\"foo\">bar</div>"), "HTML passes through")
fn test_heading_in_list(): Unit with {Test} =
Test.assertEqualMsg("<ul>\n<li><h3>Title</h3></li>\n</ul>\n", lib.toHtml("- ### Title"), "heading inside list item")