Add a three-paragraph incremental article demo
This commit is contained in:
1 parent
e05caa351b
commit
4de329c327
3 files changed
+44
-1
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
//! M0 demo: a three-paragraph article whose middle paragraph is edited.
|
||||
//!
|
||||
//! Run with `cargo run -p texrra-tex-core --example incremental_article`.
|
||||
//! It prints the page count before/after the edit and the pages that the
|
||||
//! checkpoint replay had to rebuild.
|
||||
|
||||
use texrra_tex_core::{Document, Engine, ParagraphStyle, Unit};
|
||||
|
||||
fn paragraph(id: u64, marker: &str) -> Unit {
|
||||
// Roughly one page of 10pt text at a 300pt page goal.
|
||||
let text = format!("{} {}", marker, "alpha beta gamma delta ".repeat(80));
|
||||
Unit::paragraph_with_style(id, text, ParagraphStyle::default())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let document = Document::new(
|
||||
300,
|
||||
vec![
|
||||
paragraph(1, "ONE"),
|
||||
paragraph(2, "TWO"),
|
||||
paragraph(3, "THREE"),
|
||||
],
|
||||
);
|
||||
let mut engine = Engine::layout(&document);
|
||||
println!(
|
||||
"initial: pages={} changed={:?}",
|
||||
engine.pages().len(),
|
||||
engine.changed_pages()
|
||||
);
|
||||
|
||||
engine.edit(&document, 2, "TWO edited beta gamma delta ".repeat(60));
|
||||
println!(
|
||||
"after edit: pages={} changed={:?}",
|
||||
engine.pages().len(),
|
||||
engine.changed_pages()
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user