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), styles.chain(&style),
Region::new(Size::splat(Abs::inf()), Axes::splat(false)), 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 { } else {
engine.sink.warn(warning!( engine.sink.warn(warning!(
child.span(), child.span(),

View File

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

View File

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

View File

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