Carry TeX plus and minus on paragraph skips
This commit is contained in:
1 parent
0102a20120
commit
94559ee431
3 files changed
+113
-14
No files matched your search
@@ -246,6 +246,12 @@ pub struct Unit {
|
||||
/// Extra vertical glue before this unit (TeX `\vskip`/`\smallskip`).
|
||||
#[serde(default)]
|
||||
pub space_before: i64,
|
||||
/// Stretch of the glue before this unit.
|
||||
#[serde(default)]
|
||||
pub space_stretch: i64,
|
||||
/// Shrink of the glue before this unit.
|
||||
#[serde(default)]
|
||||
pub space_shrink: i64,
|
||||
}
|
||||
|
||||
impl Unit {
|
||||
@@ -309,6 +315,8 @@ impl Unit {
|
||||
source: "halign".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![VerticalItem::Halign(Halign {
|
||||
rows,
|
||||
column_widths,
|
||||
@@ -515,6 +523,8 @@ impl Unit {
|
||||
items: vec![VerticalItem::Paragraph(paragraph)],
|
||||
paragraph_style: Some(style),
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,6 +554,8 @@ impl Unit {
|
||||
items,
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,8 +859,8 @@ fn document_nodes(
|
||||
if unit.space_before > 0 {
|
||||
nodes.push(VerticalNode::Glue(VerticalGlue::new(
|
||||
unit.space_before,
|
||||
0,
|
||||
0,
|
||||
unit.space_stretch,
|
||||
unit.space_shrink,
|
||||
)));
|
||||
owners.push(index);
|
||||
items.push(VerticalItem::Glue(unit.space_before));
|
||||
@@ -2310,8 +2322,12 @@ impl Engine {
|
||||
})
|
||||
.unwrap_or(ParagraphFont::Roman);
|
||||
let space_before = next.units[unit_index].space_before;
|
||||
let space_stretch = next.units[unit_index].space_stretch;
|
||||
let space_shrink = next.units[unit_index].space_shrink;
|
||||
next.units[unit_index] = Unit::paragraph_with_style_and_face(unit_id, source, style, font);
|
||||
next.units[unit_index].space_before = space_before;
|
||||
next.units[unit_index].space_stretch = space_stretch;
|
||||
next.units[unit_index].space_shrink = space_shrink;
|
||||
if self.layout.checkpoints.is_empty() {
|
||||
if !self.relayout_paged_incremental(&next, unit_index) {
|
||||
self.replace_with_paged(&next);
|
||||
@@ -2865,6 +2881,8 @@ mod tests {
|
||||
source: "footnote layout".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Insertion(Insertion {
|
||||
class: 0,
|
||||
@@ -2993,6 +3011,8 @@ mod tests {
|
||||
source: String::new(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
height: 10,
|
||||
@@ -3015,6 +3035,8 @@ mod tests {
|
||||
source: "boxes".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3065,6 +3087,8 @@ mod tests {
|
||||
source: "penalty".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3129,6 +3153,8 @@ mod tests {
|
||||
source: text.to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3188,6 +3214,8 @@ mod tests {
|
||||
source: "float".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3222,6 +3250,8 @@ mod tests {
|
||||
source: "float".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3825,6 +3855,8 @@ mod tests {
|
||||
source: "bottom float".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3861,6 +3893,8 @@ mod tests {
|
||||
source: "tall bottom float".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Box(VerticalBox {
|
||||
width: 10,
|
||||
@@ -3894,6 +3928,8 @@ mod tests {
|
||||
source: "top fraction".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Float(Float {
|
||||
gap_before: 0,
|
||||
@@ -5477,6 +5513,8 @@ mod tests {
|
||||
source: "top float".to_owned(),
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
items: vec![
|
||||
VerticalItem::Float(Float {
|
||||
placement: FloatPlacement::Top,
|
||||
@@ -5916,6 +5954,8 @@ mod tests {
|
||||
}],
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
};
|
||||
let mut document =
|
||||
Document::new(100, vec![math, Unit::vskip(2, 0), Unit::rule(3, 100, 20)]);
|
||||
@@ -6006,6 +6046,8 @@ mod tests {
|
||||
}],
|
||||
paragraph_style: None,
|
||||
space_before: 0,
|
||||
space_stretch: 0,
|
||||
space_shrink: 0,
|
||||
};
|
||||
let mut document = Document::new(800_000, vec![math]);
|
||||
document.max_depth = 400_000;
|
||||
|
||||
Reference in new issue
Block a user