diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-12 12:53:50 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-12 13:20:36 +0100 |
| commit | ad05ba59256a67f429b71a8aba2cd92ed2cafac7 (patch) | |
| tree | 019ccf26f7308d907c042624ccbb647f76d3491b /library/src/math/ctx.rs | |
| parent | 2720a44b965d29e9c3453c732e38554fdb6413bb (diff) | |
Spans in math
Diffstat (limited to 'library/src/math/ctx.rs')
| -rw-r--r-- | library/src/math/ctx.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/library/src/math/ctx.rs b/library/src/math/ctx.rs index 991d582c..bd44546d 100644 --- a/library/src/math/ctx.rs +++ b/library/src/math/ctx.rs @@ -124,13 +124,15 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { .into_frame()) } - pub fn layout_text(&mut self, text: &str) -> SourceResult<()> { + pub fn layout_text(&mut self, node: &TextNode) -> SourceResult<()> { + let text = node.text(); + let span = node.span(); let mut chars = text.chars(); if let Some(glyph) = chars .next() .filter(|_| chars.next().is_none()) .map(|c| self.style.styled_char(c)) - .and_then(|c| GlyphFragment::try_new(self, c)) + .and_then(|c| GlyphFragment::try_new(self, c, span)) { // A single letter that is available in the math font. if self.style.size == MathSize::Display @@ -146,7 +148,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { let mut fragments = vec![]; for c in text.chars() { let c = self.style.styled_char(c); - fragments.push(GlyphFragment::new(self, c).into()); + fragments.push(GlyphFragment::new(self, c, span).into()); } let frame = MathRow::new(fragments).to_frame(self); self.push(FrameFragment::new(self, frame)); @@ -158,7 +160,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> { style = style.with_italic(false); } let text: EcoString = text.chars().map(|c| style.styled_char(c)).collect(); - let frame = self.layout_content(&TextNode::packed(text))?; + let frame = self.layout_content(&TextNode::packed(text).spanned(span))?; self.push( FrameFragment::new(self, frame) .with_class(MathClass::Alphabetic) |
