diff options
Diffstat (limited to 'library')
| -rw-r--r-- | library/src/layout/mod.rs | 8 | ||||
| -rw-r--r-- | library/src/lib.rs | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/library/src/layout/mod.rs b/library/src/layout/mod.rs index 605da3b2..5812115a 100644 --- a/library/src/layout/mod.rs +++ b/library/src/layout/mod.rs @@ -33,7 +33,7 @@ use typst::frame::Frame; use typst::geom::*; use typst::model::{ capability, Content, Node, SequenceNode, Show, StyleChain, StyleEntry, - StyleVecBuilder, StyledNode, Target, + StyleVecBuilder, StyledNode, }; use typst::World; @@ -312,8 +312,8 @@ impl<'a> Builder<'a> { content: &'a Content, styles: StyleChain<'a>, ) -> SourceResult<()> { - if let Some(text) = content.downcast::<TextNode>() { - if let Some(realized) = styles.apply(self.world, Target::Text(&text.0))? { + if content.is::<TextNode>() { + if let Some(realized) = styles.apply(self.world, content)? { let stored = self.scratch.content.alloc(realized); return self.accept(stored, styles); } @@ -362,7 +362,7 @@ impl<'a> Builder<'a> { } fn show(&mut self, content: &Content, styles: StyleChain<'a>) -> SourceResult<bool> { - let Some(realized) = styles.apply(self.world, Target::Node(content))? else { + let Some(realized) = styles.apply(self.world, content)? else { return Ok(false); }; diff --git a/library/src/lib.rs b/library/src/lib.rs index 6f77e0f3..ca10837f 100644 --- a/library/src/lib.rs +++ b/library/src/lib.rs @@ -10,7 +10,7 @@ pub mod structure; pub mod text; use typst::geom::{Align, Color, Dir, GenAlign}; -use typst::model::{LangItems, Node, Scope, StyleMap}; +use typst::model::{LangItems, Node, NodeId, Scope, StyleMap}; use self::layout::LayoutRoot; @@ -160,6 +160,8 @@ pub fn items() -> LangItems { space: || text::SpaceNode.pack(), linebreak: |justify| text::LinebreakNode { justify }.pack(), text: |text| text::TextNode(text).pack(), + text_id: NodeId::of::<text::TextNode>(), + text_str: |content| Some(&content.downcast::<text::TextNode>()?.0), smart_quote: |double| text::SmartQuoteNode { double }.pack(), parbreak: || text::ParbreakNode.pack(), strong: |body| text::StrongNode(body).pack(), |
