summaryrefslogtreecommitdiff
path: root/crates/typst-library/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-library/src')
-rw-r--r--crates/typst-library/src/html/dom.rs17
-rw-r--r--crates/typst-library/src/introspection/introspector.rs2
2 files changed, 15 insertions, 4 deletions
diff --git a/crates/typst-library/src/html/dom.rs b/crates/typst-library/src/html/dom.rs
index 35d513c1..47bcf995 100644
--- a/crates/typst-library/src/html/dom.rs
+++ b/crates/typst-library/src/html/dom.rs
@@ -7,7 +7,7 @@ use typst_utils::{PicoStr, ResolvedPicoStr};
use crate::diag::{bail, HintedStrResult, StrResult};
use crate::foundations::{cast, Dict, Repr, Str};
use crate::introspection::{Introspector, Tag};
-use crate::layout::Frame;
+use crate::layout::{Abs, Frame};
use crate::model::DocumentInfo;
/// An HTML document.
@@ -30,8 +30,8 @@ pub enum HtmlNode {
Text(EcoString, Span),
/// Another element.
Element(HtmlElement),
- /// A frame that will be displayed as an embedded SVG.
- Frame(Frame),
+ /// Layouted content that will be embedded into HTML as an SVG.
+ Frame(HtmlFrame),
}
impl HtmlNode {
@@ -263,6 +263,17 @@ cast! {
v: Str => Self::intern(&v)?,
}
+/// Layouted content that will be embedded into HTML as an SVG.
+#[derive(Debug, Clone, Hash)]
+pub struct HtmlFrame {
+ /// The frame that will be displayed as an SVG.
+ pub inner: Frame,
+ /// The text size where the frame was defined. This is used to size the
+ /// frame with em units to make text in and outside of the frame sized
+ /// consistently.
+ pub text_size: Abs,
+}
+
/// Defines syntactical properties of HTML tags, attributes, and text.
pub mod charsets {
/// Check whether a character is in a tag name.
diff --git a/crates/typst-library/src/introspection/introspector.rs b/crates/typst-library/src/introspection/introspector.rs
index 9751dfcb..d2ad0525 100644
--- a/crates/typst-library/src/introspection/introspector.rs
+++ b/crates/typst-library/src/introspection/introspector.rs
@@ -446,7 +446,7 @@ impl IntrospectorBuilder {
HtmlNode::Element(elem) => self.discover_in_html(sink, &elem.children),
HtmlNode::Frame(frame) => self.discover_in_frame(
sink,
- frame,
+ &frame.inner,
NonZeroUsize::ONE,
Transform::identity(),
),