diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-12-02 15:41:39 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-12-02 15:45:18 +0100 |
| commit | 9bc90c371fb41a2d6dc08eb4673e5be15f829514 (patch) | |
| tree | 454a47ce82c2229e79a139a8bdeaed9add1e0a14 /library/src/text | |
| parent | 5110a41de1ca2236739ace2d37a1af912bb029f1 (diff) | |
Introspection
Diffstat (limited to 'library/src/text')
| -rw-r--r-- | library/src/text/raw.rs | 13 | ||||
| -rw-r--r-- | library/src/text/shaping.rs | 8 |
2 files changed, 15 insertions, 6 deletions
diff --git a/library/src/text/raw.rs b/library/src/text/raw.rs index c0bf105f..9c04fedf 100644 --- a/library/src/text/raw.rs +++ b/library/src/text/raw.rs @@ -42,6 +42,19 @@ impl RawNode { } } +impl Prepare for RawNode { + fn prepare(&self, _: &mut Vt, mut this: Content, styles: StyleChain) -> Content { + this.push_field( + "lang", + match styles.get(Self::LANG) { + Some(lang) => Value::Str(lang.clone().into()), + None => Value::None, + }, + ); + this + } +} + impl Show for RawNode { fn show(&self, _: &mut Vt, _: &Content, styles: StyleChain) -> Content { let lang = styles.get(Self::LANG).as_ref().map(|s| s.to_lowercase()); diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs index 6dbbb535..6d4e41dc 100644 --- a/library/src/text/shaping.rs +++ b/library/src/text/shaping.rs @@ -6,7 +6,6 @@ use typst::font::{Font, FontVariant}; use typst::util::SliceExt; use super::*; -use crate::meta::LinkNode; use crate::prelude::*; /// The result of shaping text. @@ -93,7 +92,6 @@ impl<'a> ShapedText<'a> { let lang = self.styles.get(TextNode::LANG); let decos = self.styles.get(TextNode::DECO); let fill = self.styles.get(TextNode::FILL); - let link = self.styles.get(LinkNode::DEST); for ((font, y_offset), group) in self.glyphs.as_ref().group_by_key(|g| (g.font.clone(), g.y_offset)) @@ -128,10 +126,8 @@ impl<'a> ShapedText<'a> { offset += width; } - // Apply link if it exists. - if let Some(dest) = link { - frame.link(dest.clone()); - } + // Apply metadata. + frame.meta(self.styles); frame } |
