mirror of
https://github.com/typst/typst
synced 2025-08-26 12:44:14 +08:00
Fix nested HTML frames (#6509)
This commit is contained in:
parent
5dd5771df0
commit
7420ec972f
@ -18,7 +18,7 @@ use typst_library::foundations::{
|
|||||||
SequenceElem, Show, ShowSet, Style, StyleChain, StyledElem, Styles, SymbolElem,
|
SequenceElem, Show, ShowSet, Style, StyleChain, StyledElem, Styles, SymbolElem,
|
||||||
Synthesize, Transformation,
|
Synthesize, Transformation,
|
||||||
};
|
};
|
||||||
use typst_library::html::{tag, HtmlElem};
|
use typst_library::html::{tag, FrameElem, HtmlElem};
|
||||||
use typst_library::introspection::{Locatable, SplitLocator, Tag, TagElem};
|
use typst_library::introspection::{Locatable, SplitLocator, Tag, TagElem};
|
||||||
use typst_library::layout::{
|
use typst_library::layout::{
|
||||||
AlignElem, BoxElem, HElem, InlineElem, PageElem, PagebreakElem, VElem,
|
AlignElem, BoxElem, HElem, InlineElem, PageElem, PagebreakElem, VElem,
|
||||||
@ -237,9 +237,9 @@ fn visit<'a>(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transformations for math content based on the realization kind. Needs
|
// Transformations for content based on the realization kind. Needs
|
||||||
// to happen before show rules.
|
// to happen before show rules.
|
||||||
if visit_math_rules(s, content, styles)? {
|
if visit_kind_rules(s, content, styles)? {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,9 +280,8 @@ fn visit<'a>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles special cases for math in normal content and nested equations in
|
// Handles transformations based on the realization kind.
|
||||||
// math.
|
fn visit_kind_rules<'a>(
|
||||||
fn visit_math_rules<'a>(
|
|
||||||
s: &mut State<'a, '_, '_, '_>,
|
s: &mut State<'a, '_, '_, '_>,
|
||||||
content: &'a Content,
|
content: &'a Content,
|
||||||
styles: StyleChain<'a>,
|
styles: StyleChain<'a>,
|
||||||
@ -335,6 +334,13 @@ fn visit_math_rules<'a>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !s.kind.is_html() {
|
||||||
|
if let Some(elem) = content.to_packed::<FrameElem>() {
|
||||||
|
visit(s, &elem.body, styles)?;
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
tests/ref/html-frame-in-layout.png
Normal file
BIN
tests/ref/html-frame-in-layout.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 B |
8
tests/suite/html/frame.typ
Normal file
8
tests/suite/html/frame.typ
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// No proper HTML tests here yet because we don't want to test SVG export just
|
||||||
|
// yet. We'll definitely add tests at some point.
|
||||||
|
|
||||||
|
--- html-frame-in-layout ---
|
||||||
|
// Ensure that HTML frames are transparent in layout. This is less important for
|
||||||
|
// actual paged export than for _nested_ HTML frames, which take the same code
|
||||||
|
// path.
|
||||||
|
#html.frame[A]
|
Loading…
x
Reference in New Issue
Block a user