Add span to html.frame node (#6716)

This commit is contained in:
Laurenz 2025-08-07 18:37:07 +02:00 committed by GitHub
parent a16a4e974d
commit da6aedf7a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View File

@ -101,7 +101,7 @@ fn handle(
styles.chain(&style),
Region::new(Size::splat(Abs::inf()), Axes::splat(false)),
)?;
output.push(HtmlNode::Frame(HtmlFrame::new(frame, styles)));
output.push(HtmlNode::Frame(HtmlFrame::new(frame, styles, elem.span())));
} else {
engine.sink.warn(warning!(
child.span(),

View File

@ -338,16 +338,19 @@ pub struct HtmlFrame {
pub id: Option<EcoString>,
/// IDs to assign to destination jump points within the SVG.
pub link_points: EcoVec<(Point, EcoString)>,
/// The span from which the frame originated.
pub span: Span,
}
impl HtmlFrame {
/// Wraps a laid-out frame.
pub fn new(inner: Frame, styles: StyleChain) -> Self {
pub fn new(inner: Frame, styles: StyleChain, span: Span) -> Self {
Self {
inner,
text_size: styles.resolve(TextElem::size),
id: None,
link_points: EcoVec::new(),
span,
}
}
}

View File

@ -215,12 +215,9 @@ fn collect_raw_text(element: &HtmlElement) -> SourceResult<String> {
match c {
HtmlNode::Tag(_) => continue,
HtmlNode::Text(text, _) => output.push_str(text),
HtmlNode::Element(_) | HtmlNode::Frame(_) => {
let span = match c {
HtmlNode::Element(child) => child.span,
_ => element.span,
};
bail!(span, "HTML raw text element cannot have non-text children")
HtmlNode::Element(HtmlElement { span, .. })
| HtmlNode::Frame(HtmlFrame { span, .. }) => {
bail!(*span, "HTML raw text element cannot have non-text children")
}
};
}

View File

@ -53,8 +53,8 @@
#html.script(html.strong[Hello])
--- html-raw-text-contains-frame html ---
// Error: 2-29 HTML raw text element cannot have non-text children
#html.script(html.frame[Ok])
// Error: 14-31 HTML raw text element cannot have non-text children
#html.script(html.frame[Hello])
--- html-raw-text-contains-closing-tag html ---
// Error: 2-32 HTML raw text element cannot contain its own closing tag