feat: let a site render its xhtmlmp/html output as a Mews Profile page
All checks were successful
CI / check (push) Successful in 48s
CI / release (push) Successful in 6m48s

A new mews_profile site setting switches the XHTML-MP 1.2 doctype, the
conformance marker, the viewport tag and the default stylesheet link, and
drops raw HTML passthrough and off-site or data: images that the profile's
permitted-element list cannot vouch for.
This commit is contained in:
randogoth 2026-10-11 08:22:52 +03:00
parent 1b47145522
commit c9bde15f5c
9 changed files with 357 additions and 70 deletions

View file

@ -58,7 +58,8 @@ mod tests {
/// assertions read as the content itself.
fn render_with(settings: &PageSettings, width: u16, markdown: &str) -> String {
let doc = parse::markdown(markdown).unwrap();
let ctx = RenderCtx { url: "/x", title: "T", settings, width: Some(width) };
let ctx =
RenderCtx { url: "/x", title: "T", settings, width: Some(width), mews_hosts: None };
String::from_utf8(Text.render(&doc, &ctx).unwrap().body).unwrap()
}
@ -213,7 +214,8 @@ mod tests {
/// `parse::document`, which needs a file, so the unit tests build them.
fn render_blocks(settings: &PageSettings, width: u16, blocks: Vec<Block>) -> String {
let doc = Doc { blocks, first_h1: None };
let ctx = RenderCtx { url: "/x", title: "T", settings, width: Some(width) };
let ctx =
RenderCtx { url: "/x", title: "T", settings, width: Some(width), mews_hosts: None };
String::from_utf8(Text.render(&doc, &ctx).unwrap().body).unwrap()
}
@ -267,7 +269,13 @@ mod separation_tests {
fn render(markdown: &str) -> String {
let doc = parse::markdown(markdown).unwrap();
let settings = PageSettings { margin_left: 0, margin_right: 0, ..Default::default() };
let ctx = RenderCtx { url: "/x", title: "T", settings: &settings, width: Some(40) };
let ctx = RenderCtx {
url: "/x",
title: "T",
settings: &settings,
width: Some(40),
mews_hosts: None,
};
String::from_utf8(Text.render(&doc, &ctx).unwrap().body).unwrap()
}
@ -299,7 +307,8 @@ mod optional_feature_tests {
fn render_with(settings: &PageSettings, width: u16, markdown: &str) -> String {
let doc = parse::markdown(markdown).unwrap();
let ctx = RenderCtx { url: "/x", title: "T", settings, width: Some(width) };
let ctx =
RenderCtx { url: "/x", title: "T", settings, width: Some(width), mews_hosts: None };
String::from_utf8(Text.render(&doc, &ctx).unwrap().body).unwrap()
}