summaryrefslogtreecommitdiff
path: root/library/src/math/mod.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-01-27 15:09:05 +0100
committerLaurenz <laurmaedje@gmail.com>2023-01-27 15:32:05 +0100
commit2e039cb052fcb768027053cbf02ce396f6d7a6be (patch)
treeb1a1c1da0440805b296e3204fa30cd9666322a0e /library/src/math/mod.rs
parenta59b9fff93f708d5a35d2bf61c3b21efee71b7e9 (diff)
Fix math spacing bugs
Diffstat (limited to 'library/src/math/mod.rs')
-rw-r--r--library/src/math/mod.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 1e7a6580..2cc8fa9e 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -43,6 +43,7 @@ use self::row::*;
use self::spacing::*;
use crate::layout::HNode;
use crate::layout::ParNode;
+use crate::layout::Spacing;
use crate::prelude::*;
use crate::text::LinebreakNode;
use crate::text::TextNode;
@@ -222,6 +223,7 @@ impl LayoutMath for FormulaNode {
impl LayoutMath for Content {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
if self.is::<SpaceNode>() {
+ ctx.push(MathFragment::Space);
return Ok(());
}
@@ -230,6 +232,17 @@ impl LayoutMath for Content {
return Ok(());
}
+ if let Some(node) = self.to::<HNode>() {
+ if let Spacing::Relative(rel) = node.amount {
+ if rel.rel.is_zero() {
+ ctx.push(MathFragment::Spacing(
+ rel.abs.resolve(ctx.outer.chain(&ctx.map)),
+ ));
+ }
+ }
+ return Ok(());
+ }
+
if let Some(node) = self.to::<SequenceNode>() {
for child in &node.0 {
child.layout_math(ctx)?;
@@ -242,7 +255,7 @@ impl LayoutMath for Content {
}
let frame = ctx.layout_non_math(self)?;
- ctx.push(frame);
+ ctx.push(FrameFragment::new(frame).with_spaced(true));
Ok(())
}