Skip to main content

Page

Struct Page 

Source
pub struct Page {
Show 19 fields pub id: String, pub name: Option<String>, pub width: Dimension, pub height: Dimension, pub background: Option<PropertyValue>, pub bleed: Option<Dimension>, pub margin_inner: Option<Dimension>, pub margin_outer: Option<Dimension>, pub margin_top: Option<Dimension>, pub margin_bottom: Option<Dimension>, pub baseline_grid: Option<Dimension>, pub line_jumps: Option<String>, pub safe_zones: Vec<SafeZone>, pub folds: Vec<Fold>, pub block_styles: Vec<BlockStyle>, pub parity: Option<String>, pub master: Option<String>, pub children: Vec<Node>, pub source_span: Option<Span>,
}
Expand description

A single page within a document body.

Fields§

§id: String§name: Option<String>§width: Dimension

Page width — required.

§height: Dimension

Page height — required.

§background: Option<PropertyValue>§bleed: Option<Dimension>

Optional uniform print-bleed margin applied to all four sides. When this resolves to a positive pixel value b, the rendered media box expands to (width + 2b) × (height + 2b), all page content shifts into the inner trim box [b, b, width, height], the background fills the entire media box (bleeding off the trim edge), and crop/trim marks are auto-drawn in the bleed margin at the four trim corners. None or a non-positive value renders byte-identically to a page with no bleed.

§margin_inner: Option<Dimension>

Book live-area margin (gutter side). With document mirror_margins=true this is the BINDING-side margin: it sits on the LEFT for a recto (odd, 1-based) page and on the RIGHT for a verso (even) page. Without mirroring it is treated uniformly as the left margin. None → no inner margin.

Margins are v0 METADATA + VALIDATION ONLY: they describe the intended live area and drive the margin.violation advisory, but they do NOT auto-reposition arbitrary page nodes (that is the job of master pages / flow frames). See crate::validate()’s margin check.

§margin_outer: Option<Dimension>

Book live-area margin (fore-edge side). The mirror of Page::margin_inner: with mirror_margins=true it sits on the RIGHT for a recto page and on the LEFT for a verso page; without mirroring it is the right margin. None → no outer margin. Metadata + validation only (see margin_inner).

§margin_top: Option<Dimension>

Book live-area top margin. None → no top margin. Metadata + validation only (see Page::margin_inner).

§margin_bottom: Option<Dimension>

Book live-area bottom margin. None → no bottom margin. Metadata + validation only (see Page::margin_inner).

§baseline_grid: Option<Dimension>

Optional baseline-grid pitch in pixels. When this resolves to a positive pixel value g, every text node on this page snaps its line baselines onto the grid { 0, g, 2g, ... } measured from the page top (y=0): the first line’s baseline moves DOWN to the next grid line at or below its natural position, and the effective inter-line advance becomes the smallest multiple of g that is ≥ the resolved line-height, so corresponding lines align horizontally across columns. None or a non-positive value renders byte-identically to a page with no grid. KDL: baseline-grid=(px)14.

§line_jumps: Option<String>

Optional page-level line-jump style for connector-vs-connector crossings. When Some("arc") or Some("gap"), every place where two top-level connectors cross gains a deterministic hop on one of the two strokes (a small semicircular bump for arc, a broken gap for gap) so overlapping connectors read clearly. Some("none"), None, or any unrecognized value renders byte-identically to a page with no line jumps. An unrecognized value is surfaced as a validation warning (page.invalid_line_jumps).

§safe_zones: Vec<SafeZone>

Author-declared safe/dead zones for this page. These are not rendering nodes; the validator checks page children against them.

§folds: Vec<Fold>

Author-declared fold-line positions for this page (tri-fold/bi-fold print). These are non-printing page metadata, not rendering nodes; the validator advises when content crosses a fold line.

§block_styles: Vec<BlockStyle>

Per-role markdown block style declarations at page scope. Empty when no block role="…" children are declared on this page. Cascade precedence: page < text (the text node’s own decls override these). block decls are data-only in this unit; the layout engine consumes them later.

§parity: Option<String>

Optional explicit recto/verso parity OVERRIDE for this page. Some("recto") or Some("verso") forces this page’s parity regardless of its 1-based position and the document page_parity_start. None (default) → parity is derived from the page position and the document start parity. An invalid value is preserved verbatim and surfaced as a validation warning (page.invalid_parity); it then falls through to the derived parity. See Document::page_is_recto.

§master: Option<String>

Optional master-page reference. When Some(id) names a declared MasterDef, the master’s nodes (running heads, folios, TOC refs) are projected UNDER this page’s own children at compile time — the master’s Field nodes are resolved against this page’s index/parity. An unknown reference is a hard master.unknown_reference validation error. None → the page has no master (renders as before).

§children: Vec<Node>

Child content nodes in z-order (first = bottommost, last = topmost).

§source_span: Option<Span>

Source declaration span, when available.

Trait Implementations§

Source§

impl Clone for Page

Source§

fn clone(&self) -> Page

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Page

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Page

Source§

fn eq(&self, other: &Page) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Page

Auto Trait Implementations§

§

impl Freeze for Page

§

impl RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl UnsafeUnpin for Page

§

impl UnwindSafe for Page

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.