mirror of
https://github.com/typst/typst
synced 2025-08-12 06:07:54 +08:00
Add span to html.frame
node (#6716)
This commit is contained in:
parent
a16a4e974d
commit
da6aedf7a4
@ -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(),
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user