pub struct Book {
pub metadata: Metadata,
pub sections: Vec<Section>,
}Expand description
The root of the content tree: one book.
Fields§
§metadata: MetadataThe work’s title, author and frontend extensions.
sections: Vec<Section>The chapters/files, in reading order.
Implementations§
Source§impl Book
impl Book
Sourcepub fn anchors(&self) -> Anchors
pub fn anchors(&self) -> Anchors
What the links in this book can reach.
Read it after Book::assign_node_ids, because the nodes it
gives are the ids that numbering assigns.
Source§impl Book
impl Book
Sourcepub fn assign_node_ids(&mut self)
pub fn assign_node_ids(&mut self)
Assign ids to every node, in document order (pre-order: a node before its children, sections in reading order), starting at 1. Runs once, after deserialization; running it again renumbers.
Sourcepub fn node_at(&self, source: &str, byte: u32) -> Option<NodeId>
pub fn node_at(&self, source: &str, byte: u32) -> Option<NodeId>
The node one byte of one source was read into: the innermost, so a byte of prose answers with the run it was typed into and a byte of markup answers with the construct it opens.
Only sections read from that source are looked at, so one file’s cursor is answered by one file’s nodes. Nothing for a byte no node was read from, such as a blank line between chapters or a source’s frontmatter, and nothing for a tree built rather than parsed.
Sourcepub fn source_of(&self, node: NodeId) -> Option<(&str, SourceSpan)>
pub fn source_of(&self, node: NodeId) -> Option<(&str, SourceSpan)>
The source a node was read from, and the bytes of it the node covers.
Nothing for a node the engine synthesized, or one from a tree built rather than parsed: neither was read from anything.
Sourcepub fn names(&self, source: Option<&str>) -> Names
pub fn names(&self, source: Option<&str>) -> Names
The classes and the ids the blocks and inlines of one source
carry, or of every source when source is None. A list
item, a table row or cell, and a note count as blocks and
inlines here.
A section’s own names are not in the answer. A host sets them beside the source, or frontmatter writes them.
Sourcepub fn subtree(&self, node: NodeId) -> Option<Range<u32>>
pub fn subtree(&self, node: NodeId) -> Option<Range<u32>>
The ids one node and its descendants hold.
Ids are assigned in document order, a node before its children, so what a node covers is a run of consecutive numbers. Asking what a node was set from is asking about every id in this range.
Nothing for a node the book does not hold.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Book
impl<'de> Deserialize<'de> for Book
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Book
Auto Trait Implementations§
impl Freeze for Book
impl RefUnwindSafe for Book
impl Send for Book
impl Sync for Book
impl Unpin for Book
impl UnsafeUnpin for Book
impl UnwindSafe for Book
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.