Support classed marks in the output routine
This commit is contained in:
1 parent
91171f2a90
commit
a93200cbfb
4 files changed
+76
-34
No files matched your search
@@ -1524,7 +1524,7 @@ struct PagedOutput {
|
||||
skips: [i64; 256],
|
||||
initial_dimens: Vec<(u8, i64)>,
|
||||
initial_skips: Vec<(u8, i64)>,
|
||||
pending_marks: Vec<String>,
|
||||
pending_marks: Vec<(u8, String)>,
|
||||
}
|
||||
|
||||
impl PagedOutput {
|
||||
@@ -2196,7 +2196,7 @@ impl Engine {
|
||||
let mut pages = Vec::new();
|
||||
let mut held: BTreeMap<u8, Vec<VerticalItem>> = BTreeMap::new();
|
||||
let mut fragments = builder.build_with_deferred_bottom_floats(&nodes);
|
||||
let mut carried_marks: Vec<String> = Vec::new();
|
||||
let mut carried_marks: Vec<(u8, String)> = Vec::new();
|
||||
let mut page_index = 0;
|
||||
while page_index < fragments.len() {
|
||||
let fragment = fragments[page_index].clone();
|
||||
@@ -2279,7 +2279,7 @@ impl Engine {
|
||||
if !carried_marks.is_empty() {
|
||||
let mut marks_with_carry: Vec<Mark> = std::mem::take(&mut carried_marks)
|
||||
.into_iter()
|
||||
.map(|text| Mark { class: 0, text })
|
||||
.map(|(class, text)| Mark { class, text })
|
||||
.collect();
|
||||
marks_with_carry.append(&mut marks);
|
||||
marks = marks_with_carry;
|
||||
@@ -3484,6 +3484,24 @@ mod tests {
|
||||
assert_eq!(engine.layout.pages[1].marks[0].class, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_marks_carry_their_class() {
|
||||
let mut units = Vec::new();
|
||||
for step in 0..3_u64 {
|
||||
units.push(Unit::rule(step * 2, 300, 600));
|
||||
if step < 2 {
|
||||
units.push(Unit::vskip(step * 2 + 1, 0));
|
||||
}
|
||||
}
|
||||
let mut document = Document::new(1000, units);
|
||||
document.top_skip = 0;
|
||||
document.output_routine = Some(r"\marks3{carried}\shipout\box255".to_owned());
|
||||
let engine = Engine::layout_paged(&document).expect("paged");
|
||||
assert_eq!(engine.layout.pages.len(), 3);
|
||||
assert_eq!(engine.layout.pages[1].marks[0].class, 3);
|
||||
assert_eq!(engine.layout.pages[1].marks[0].text, "carried");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn output_routine_can_advance_vsize_for_later_pages() {
|
||||
let mut units = Vec::new();
|
||||
|
||||
Reference in new issue
Block a user