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

111
packages/rss/test_unit.lux Normal file
View File

@@ -0,0 +1,111 @@
import lib
// --- item creation ---
fn test_item_defaults_guid_to_link(): Unit with {Test} = {
let i = lib.item("Title", "https://example.com/post", "Desc", "2025-01-01")
Test.assertEqualMsg("https://example.com/post", lib.itemGuid(i), "guid defaults to link")
}
fn test_item_with_custom_guid(): Unit with {Test} = {
let i = lib.itemWithGuid("Title", "https://example.com", "Desc", "2025-01-01", "custom-123")
Test.assertEqualMsg("custom-123", lib.itemGuid(i), "custom guid preserved")
}
fn test_item_empty_fields(): Unit with {Test} = {
let i = lib.item("", "", "", "")
Test.assertEqualMsg("", lib.itemTitle(i), "empty title")
Test.assertEqualMsg("", lib.itemLink(i), "empty link")
Test.assertEqualMsg("", lib.itemDescription(i), "empty description")
Test.assertEqualMsg("", lib.itemPubDate(i), "empty pubDate")
}
fn test_item_special_chars(): Unit with {Test} = {
let i = lib.item("A & B <C>", "https://example.com?a=1&b=2", "\"quotes\" & <tags>", "2025-01-01")
Test.assertEqualMsg("A & B <C>", lib.itemTitle(i), "special chars in title preserved")
Test.assertEqualMsg("\"quotes\" & <tags>", lib.itemDescription(i), "special chars in desc preserved")
}
// --- all accessor functions ---
fn test_item_accessors(): Unit with {Test} = {
let i = lib.item("T", "L", "D", "P")
Test.assertEqualMsg("T", lib.itemTitle(i), "itemTitle")
Test.assertEqualMsg("L", lib.itemLink(i), "itemLink")
Test.assertEqualMsg("D", lib.itemDescription(i), "itemDescription")
Test.assertEqualMsg("P", lib.itemPubDate(i), "itemPubDate")
Test.assertEqualMsg("L", lib.itemGuid(i), "itemGuid defaults to link")
}
// --- date conversion for all months ---
fn test_date_january(): Unit with {Test} =
Test.assertEqualMsg("15 Jan 2025 00:00:00 GMT", lib.isoToRfc822("2025-01-15"), "January")
fn test_date_february(): Unit with {Test} =
Test.assertEqualMsg("28 Feb 2025 00:00:00 GMT", lib.isoToRfc822("2025-02-28"), "February")
fn test_date_march(): Unit with {Test} =
Test.assertEqualMsg("01 Mar 2025 00:00:00 GMT", lib.isoToRfc822("2025-03-01"), "March")
fn test_date_april(): Unit with {Test} =
Test.assertEqualMsg("30 Apr 2025 00:00:00 GMT", lib.isoToRfc822("2025-04-30"), "April")
fn test_date_may(): Unit with {Test} =
Test.assertEqualMsg("01 May 2025 00:00:00 GMT", lib.isoToRfc822("2025-05-01"), "May")
fn test_date_june(): Unit with {Test} =
Test.assertEqualMsg("15 Jun 2025 00:00:00 GMT", lib.isoToRfc822("2025-06-15"), "June")
fn test_date_july(): Unit with {Test} =
Test.assertEqualMsg("04 Jul 2025 00:00:00 GMT", lib.isoToRfc822("2025-07-04"), "July")
fn test_date_august(): Unit with {Test} =
Test.assertEqualMsg("20 Aug 2025 00:00:00 GMT", lib.isoToRfc822("2025-08-20"), "August")
fn test_date_september(): Unit with {Test} =
Test.assertEqualMsg("10 Sep 2025 00:00:00 GMT", lib.isoToRfc822("2025-09-10"), "September")
fn test_date_october(): Unit with {Test} =
Test.assertEqualMsg("31 Oct 2025 00:00:00 GMT", lib.isoToRfc822("2025-10-31"), "October")
fn test_date_november(): Unit with {Test} =
Test.assertEqualMsg("11 Nov 2025 00:00:00 GMT", lib.isoToRfc822("2025-11-11"), "November")
fn test_date_december(): Unit with {Test} =
Test.assertEqualMsg("25 Dec 2025 00:00:00 GMT", lib.isoToRfc822("2025-12-25"), "December")
fn test_date_short_string(): Unit with {Test} =
Test.assertEqualMsg("bad", lib.isoToRfc822("bad"), "short string passthrough")
fn test_date_empty(): Unit with {Test} =
Test.assertEqualMsg("", lib.isoToRfc822(""), "empty date passthrough")
fn test_date_partial(): Unit with {Test} =
Test.assertEqualMsg("2025-01", lib.isoToRfc822("2025-01"), "partial date passthrough")
// --- feed creation ---
fn test_feed_default_language(): Unit with {Test} = {
let f = lib.feed("Title", "https://example.com", "Desc", [])
let xml = lib.render(f)
Test.assert(String.contains(xml, "<language>en</language>"), "default language is en")
}
fn test_feed_custom_language(): Unit with {Test} = {
let f = lib.feedWithLang("Title", "https://example.com", "Desc", "fr", [])
let xml = lib.render(f)
Test.assert(String.contains(xml, "<language>fr</language>"), "custom language fr")
}
fn test_feed_escapes_title(): Unit with {Test} = {
let f = lib.feed("A & B", "https://example.com", "Desc", [])
let xml = lib.render(f)
Test.assert(String.contains(xml, "<title>A &amp; B</title>"), "feed title is escaped")
}
fn test_feed_escapes_description(): Unit with {Test} = {
let f = lib.feed("Title", "https://example.com", "<b>Bold</b> desc", [])
let xml = lib.render(f)
Test.assert(String.contains(xml, "&lt;b&gt;Bold&lt;/b&gt;"), "feed description is escaped")
}