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

118
packages/xml/test_unit.lux Normal file
View File

@@ -0,0 +1,118 @@
import lib
// --- escape edge cases ---
fn test_escape_all_chars(): Unit with {Test} = {
Test.assertEqualMsg("&", lib.escape("&"), "escape ampersand")
Test.assertEqualMsg("&lt;", lib.escape("<"), "escape less-than")
Test.assertEqualMsg("&gt;", lib.escape(">"), "escape greater-than")
Test.assertEqualMsg("&quot;", lib.escape("\""), "escape double quote")
Test.assertEqualMsg("&apos;", lib.escape("'"), "escape single quote")
}
fn test_escape_empty(): Unit with {Test} =
Test.assertEqualMsg("", lib.escape(""), "escape empty string")
fn test_escape_no_special(): Unit with {Test} =
Test.assertEqualMsg("hello world 123", lib.escape("hello world 123"), "escape plain text unchanged")
fn test_escape_all_special(): Unit with {Test} =
Test.assertEqualMsg("&lt;&amp;&gt;&quot;&apos;", lib.escape("<&>\"'"), "escape all special chars together")
fn test_escape_mixed(): Unit with {Test} =
Test.assertEqualMsg("a &amp; b &lt; c", lib.escape("a & b < c"), "escape mixed content")
// --- node constructors ---
fn test_text_node_simple(): Unit with {Test} =
Test.assertEqualMsg("hello", lib.render(lib.text("hello")), "text node renders content")
fn test_text_node_escapes(): Unit with {Test} =
Test.assertEqualMsg("&lt;script&gt;", lib.render(lib.text("<script>")), "text node escapes HTML")
fn test_text_node_empty(): Unit with {Test} =
Test.assertEqualMsg("", lib.render(lib.text("")), "empty text node")
fn test_cdata_preserves_special(): Unit with {Test} =
Test.assertEqualMsg("<![CDATA[<b>bold & stuff</b>]]>", lib.render(lib.cdata("<b>bold & stuff</b>")), "cdata preserves special chars")
fn test_raw_no_escape(): Unit with {Test} =
Test.assertEqualMsg("<br/>", lib.render(lib.raw("<br/>")), "raw passes through unchanged")
fn test_raw_empty(): Unit with {Test} =
Test.assertEqualMsg("", lib.render(lib.raw("")), "empty raw node")
// --- element rendering ---
fn test_self_closing_no_attrs(): Unit with {Test} =
Test.assertEqualMsg("<br/>", lib.render(lib.selfClosing("br", [])), "self-closing no attrs")
fn test_self_closing_with_attr(): Unit with {Test} =
Test.assertEqualMsg("<img src=\"photo.jpg\"/>", lib.render(lib.selfClosing("img", [lib.attr("src", "photo.jpg")])), "self-closing with attr")
fn test_self_closing_multiple_attrs(): Unit with {Test} = {
let node = lib.selfClosing("input", [lib.attr("type", "text"), lib.attr("name", "q"), lib.attr("value", "")])
Test.assertEqualMsg("<input type=\"text\" name=\"q\" value=\"\"/>", lib.render(node), "self-closing with multiple attrs")
}
fn test_el_empty_children(): Unit with {Test} =
Test.assertEqualMsg("<div/>", lib.render(lib.el("div", [])), "el with no children self-closes")
fn test_el_with_children(): Unit with {Test} = {
let node = lib.el("ul", [lib.textEl("li", "a"), lib.textEl("li", "b")])
Test.assertEqualMsg("<ul><li>a</li><li>b</li></ul>", lib.render(node), "el with children")
}
fn test_text_el(): Unit with {Test} =
Test.assertEqualMsg("<title>Hello</title>", lib.render(lib.textEl("title", "Hello")), "textEl renders correctly")
fn test_text_el_escapes(): Unit with {Test} =
Test.assertEqualMsg("<p>a &amp; b</p>", lib.render(lib.textEl("p", "a & b")), "textEl escapes content")
fn test_text_el_attr(): Unit with {Test} = {
let node = lib.textElAttr("a", [lib.attr("href", "/page")], "click")
Test.assertEqualMsg("<a href=\"/page\">click</a>", lib.render(node), "textElAttr renders correctly")
}
// --- attribute edge cases ---
fn test_attr_value_escaping(): Unit with {Test} = {
let node = lib.selfClosing("div", [lib.attr("data", "a&b<c\"d'e")])
Test.assertEqualMsg("<div data=\"a&amp;b&lt;c&quot;d&apos;e\"/>", lib.render(node), "attr value escapes all special chars")
}
fn test_attr_empty_value(): Unit with {Test} = {
let node = lib.selfClosing("input", [lib.attr("disabled", "")])
Test.assertEqualMsg("<input disabled=\"\"/>", lib.render(node), "attr with empty value")
}
// --- nesting depth ---
fn test_deeply_nested(): Unit with {Test} = {
let deep = lib.el("a", [lib.el("b", [lib.el("c", [lib.el("d", [lib.text("deep")])])])])
Test.assertEqualMsg("<a><b><c><d>deep</d></c></b></a>", lib.render(deep), "4 levels deep")
}
// --- document ---
fn test_document_declaration(): Unit with {Test} = {
let doc = lib.document(lib.textEl("root", ""))
Test.assert(String.startsWith(doc, "<?xml version=\"1.0\""), "document starts with XML declaration")
}
fn test_document_with_custom_decl(): Unit with {Test} = {
let doc = lib.documentWithDecl("<?xml version=\"1.1\"?>", lib.textEl("root", ""))
Test.assert(String.startsWith(doc, "<?xml version=\"1.1\"?>"), "custom declaration")
}
// --- mixed children ---
fn test_mixed_children_types(): Unit with {Test} = {
let node = lib.el("div", [
lib.text("Hello "),
lib.raw("<strong>world</strong>"),
lib.text(" & "),
lib.cdata("raw data")
])
Test.assertEqualMsg("<div>Hello <strong>world</strong> &amp; <![CDATA[raw data]]></div>", lib.render(node), "mixed children types")
}