summaryrefslogtreecommitdiff
path: root/library/src/structure/doc.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-03 11:44:53 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-03 13:35:39 +0100
commit37a7afddfaffd44cb9bc013c9506599267e08983 (patch)
tree20e7d62d3c5418baff01a21d0406b91bf3096214 /library/src/structure/doc.rs
parent56342bd972a13ffe21beaf2b87ab7eb1597704b4 (diff)
Split crates
Diffstat (limited to 'library/src/structure/doc.rs')
-rw-r--r--library/src/structure/doc.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/library/src/structure/doc.rs b/library/src/structure/doc.rs
new file mode 100644
index 00000000..ac12c3ab
--- /dev/null
+++ b/library/src/structure/doc.rs
@@ -0,0 +1,29 @@
+use crate::layout::PageNode;
+use crate::prelude::*;
+
+/// A sequence of page runs.
+#[derive(Hash)]
+pub struct DocNode(pub StyleVec<PageNode>);
+
+impl DocNode {
+ /// Layout the document into a sequence of frames, one per page.
+ pub fn layout(
+ &self,
+ world: Tracked<dyn World>,
+ styles: StyleChain,
+ ) -> SourceResult<Vec<Frame>> {
+ let mut frames = vec![];
+ for (page, map) in self.0.iter() {
+ let number = 1 + frames.len();
+ frames.extend(page.layout(world, number, map.chain(&styles))?);
+ }
+ Ok(frames)
+ }
+}
+
+impl Debug for DocNode {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ f.write_str("Doc ")?;
+ self.0.fmt(f)
+ }
+}