summaryrefslogtreecommitdiff
path: root/library/src/layout
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-04-13 15:52:20 +0200
committerLaurenz <laurmaedje@gmail.com>2023-04-13 15:52:20 +0200
commit46ce9c94e3f615751989d3cba5aa1599e0ba5913 (patch)
tree4f954ffdb9bd3ac95ac51e1a8ff6b5fbca487fd9 /library/src/layout
parent9025ecb2ee3ed19865ee2078eb6c01f4660351e9 (diff)
Fix linebreak after inline objects with metadata
Diffstat (limited to 'library/src/layout')
-rw-r--r--library/src/layout/par.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs
index 17e07cd0..3385e0e7 100644
--- a/library/src/layout/par.rs
+++ b/library/src/layout/par.rs
@@ -318,7 +318,8 @@ impl Segment<'_> {
Self::Text(len) => len,
Self::Spacing(_) => SPACING_REPLACE.len_utf8(),
Self::Box(_, true) => SPACING_REPLACE.len_utf8(),
- Self::Equation(_) | Self::Box(_, _) | Self::Meta => OBJ_REPLACE.len_utf8(),
+ Self::Equation(_) | Self::Box(_, _) => OBJ_REPLACE.len_utf8(),
+ Self::Meta => 0,
}
}
}
@@ -334,6 +335,8 @@ enum Item<'a> {
Fractional(Fr, Option<(&'a BoxElem, StyleChain<'a>)>),
/// Layouted inline-level content.
Frame(Frame),
+ /// Metadata.
+ Meta(Frame),
}
impl<'a> Item<'a> {
@@ -351,6 +354,7 @@ impl<'a> Item<'a> {
Self::Text(shaped) => shaped.text.len(),
Self::Absolute(_) | Self::Fractional(_, _) => SPACING_REPLACE.len_utf8(),
Self::Frame(_) => OBJ_REPLACE.len_utf8(),
+ Self::Meta(_) => 0,
}
}
@@ -360,7 +364,7 @@ impl<'a> Item<'a> {
Self::Text(shaped) => shaped.width,
Self::Absolute(v) => *v,
Self::Frame(frame) => frame.width(),
- Self::Fractional(_, _) => Abs::zero(),
+ Self::Fractional(_, _) | Self::Meta(_) => Abs::zero(),
}
}
}
@@ -585,7 +589,6 @@ fn collect<'a>(
full.push(if frac { SPACING_REPLACE } else { OBJ_REPLACE });
Segment::Box(elem, frac)
} else if child.is::<MetaElem>() {
- full.push(OBJ_REPLACE);
Segment::Meta
} else {
bail!(child.span(), "unexpected paragraph child");
@@ -670,7 +673,7 @@ fn prepare<'a>(
Segment::Meta => {
let mut frame = Frame::new(Size::zero());
frame.meta(styles, true);
- items.push(Item::Frame(frame));
+ items.push(Item::Meta(frame));
}
}
@@ -1336,7 +1339,7 @@ fn commit(
let frame = shaped.build(vt, justification_ratio, extra_justification);
push(&mut offset, frame);
}
- Item::Frame(frame) => {
+ Item::Frame(frame) | Item::Meta(frame) => {
push(&mut offset, frame.clone());
}
}