ext/web W4c: SEO meta, Markdown render, RSS, pagination UI

Add lib/net markdown_parse, page.meta/paginate and app.route_rss author
APIs, GFM Markdown article bodies, head SEO tags, list pagination nav, and
RSS 2.0 feed routes — keeping tables + class methods as the author surface.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-28 09:46:16 +08:00
1 parent be6223f1fb
commit e7c9c21a49
18 files changed
+671 -60

No files matched your search

+6
View File
@@ -123,6 +123,7 @@ pub enum HostFn {
CollectionClear = 121,
CookieParse = 122,
MultipartParse = 123,
MarkdownParse = 124,
}
@@ -243,6 +244,7 @@ impl HostFn {
121 => Self::CollectionClear,
122 => Self::CookieParse,
123 => Self::MultipartParse,
124 => Self::MarkdownParse,
_ => return None,
})
}
@@ -366,6 +368,7 @@ impl HostFn {
"host_collection_clear" | "collection_clear" => Self::CollectionClear,
"host_cookie_parse" | "cookie_parse" => Self::CookieParse,
"host_multipart_parse" | "multipart_parse" => Self::MultipartParse,
"host_markdown_parse" | "markdown_parse" => Self::MarkdownParse,
_ => return None,
})
}
@@ -476,6 +479,7 @@ impl HostFn {
Self::CollectionClear => "host_collection_clear",
Self::CookieParse => "host_cookie_parse",
Self::MultipartParse => "host_multipart_parse",
Self::MarkdownParse => "host_markdown_parse",
Self::WritebackRecord => "host_writeback_record",
Self::WritebackGet => "host_writeback_get",
Self::WritebackClear => "host_writeback_clear",
@@ -560,6 +564,7 @@ impl HostFn {
Self::CollectionClear => &["value"],
Self::CookieParse => &["text", "is_response"],
Self::MultipartParse => &["body", "boundary"],
Self::MarkdownParse => &["text"],
Self::WritebackRecord => &["value"],
Self::WritebackGet | Self::WritebackClear => &[],
Self::WritebackList => &[],
@@ -842,6 +847,7 @@ pub fn call_host(
HostFn::CollectionClear => super::collection::collection_clear(require(bound, "value")?),
HostFn::CookieParse => net::cookie_parse(require(bound, "text")?, bound.get("is_response")),
HostFn::MultipartParse => net::multipart_parse(require(bound, "body")?, require(bound, "boundary")?),
HostFn::MarkdownParse => net::markdown_parse(require(bound, "text")?),
HostFn::OuterCallLine => Ok(Value::Int(
ctx.call_site_lines
.first()
+31
View File
@@ -448,6 +448,26 @@ pub fn multipart_parse(body: &Value, boundary: &Value) -> Result<Value, String>
Ok(Value::List(parts))
}
/// Parse Markdown / GFM into HTML (pure transform, no network I/O).
pub fn markdown_parse(text: &Value) -> Result<Value, String> {
let md = as_text(text, "text")?;
Ok(Value::Text(markdown_to_html(md)))
}
fn markdown_to_html(md: &str) -> String {
use pulldown_cmark::{html, Options, Parser};
let mut opts = Options::empty();
opts.insert(
Options::ENABLE_STRIKETHROUGH
| Options::ENABLE_TABLES
| Options::ENABLE_TASKLISTS,
);
let parser = Parser::new_ext(md, opts);
let mut html_out = String::new();
html::push_html(&mut html_out, parser);
html_out
}
/// Extract `data:` payloads from an SSE body (ignores comments / event: / id:).
pub fn sse_data_payloads(text: &str) -> Vec<String> {
let mut out = Vec::new();
@@ -981,4 +1001,15 @@ data: [DONE]\n\
.iter()
.any(|(k, v)| k == "value" && matches!(v, Value::Text(t) if t == "file body")));
}
#[test]
fn markdown_parse_basic() {
let md = Value::Text("# Hello\n\nA **bold** word.".into());
let out = markdown_parse(&md).unwrap();
let Value::Text(html) = out else {
panic!("expected text html");
};
assert!(html.contains("<h1"));
assert!(html.contains("<strong>bold</strong>"));
}
}