Guidedog Manual 1.0.0-beta.16
Idioma
En esta página
Guidedog / Documentación 1.0.0-beta.16

guidedoc

Guidedoc, the conversion engine of Guidedog: the document model, the builder readers and passes write through, validation, diagnostics, the adapter registry, and the pipeline that reads, transforms, and renders a document.

The engine imports no reader, renderer, operating system, or Typst crate. Every name is exported at the crate root, so adapters read guidedoc::begin_node-style names directly; docs/manual/internals/ast.rst is the normative node mapping.

use guidedoc::{convert_text, Registry, Workspace};
let mut ws = Workspace::new();
let registry = Registry::default(); // the defaults crate provides the real one
let failure = convert_text(&mut ws, &registry, "commonmark", "html", "# Hi\n");
assert_eq!(failure.map_err(|f| f.code()), Err("core.reader.unknown"));

Structs

pub struct guidedoc::ReadContext<'a>

What a reader works with for one read: the builder, the source being read, the options, and the source table it may add included sources to.

Fields

pub b: Builder<'a>

The builder of the document being read.

pub source: SourceId

The source to read.

pub options: &'a ReadOptions<'a>

The read options.

pub policy: Policy

The trust decisions.

pub limits: Limits

The bounds.

Implementations

impl<'a> ReadContext<'a>
pub fn reports(&mut self) -> &mut Reports

Returns the reports of the read.

pub fn take_scratch<T: Default + Send + 'static>(&mut self) -> T

Takes the reader’s working state of type T out of the workspace (see Scratch::take): what an earlier read left, or T::default(). Clear what you use and give it back with put_scratch, so the next read reuses its storage.

pub fn put_scratch<T: Send + 'static>(&mut self, value: T)

Gives working state taken with take_scratch back to the workspace.

pub fn report(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg)

Reports message m at span, filled with the arguments a and b.

pub fn source_of(&self, id: SourceId) -> SourceText<'a>

Returns the text of source id, which the reader may keep while it builds; «» for an unknown id.

pub fn source_entry(&self, id: SourceId) -> Option<&SourceEntry>

Returns the source-table entry of id (its name, parent, and include span).

pub fn source_count(&self) -> usize

Returns the number of sources in the table.

pub fn source_text(&self, span: SourceSpan) -> &str

Returns the source text a span covers, or «» for an invalid span.

pub fn document(&self) -> Document<'_>

Views the document built so far with its sources.

pub fn reader_settings<T: 'static>(&mut self) -> Result<Option<&'a T>, Fail>

Returns the reader’s settings of type T: None for the defaults when the read options carry none. Settings of another type are reported (core.read.settings_type) and fail with InvalidInput.

pub fn no_reader_settings(&mut self) -> Result<(), Fail>

The check of a reader that takes no settings: any settings are reported (core.read.settings_none) and fail with InvalidInput.

impl ReadContext<'_>
pub fn include_source(&mut self, from: SourceId, name: &str, span: SourceSpan, usage: SourceUse) -> Option<SourceId>

Asks the resource provider for name, which a directive at span in source from names, records it in the source table, and returns its id. Every refusal is reported at span and gives None; running out of sources poisons the builder. usage tells whether the reader parses the text or shows it as it is.

pub fn add_source(&mut self, name: &str, text: &str) -> Option<SourceId>

Registers text that is not a file, such as a configured prologue, so nodes parsed from it carry spans into it. The text is copied (shared) into the table.

Trait Implementations

impl fmt::Debug for ReadContext<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::Reader

A reader: a constant descriptor with functions and no state.

Fields

pub id: &'static str

Registry id («rst»).

pub name: &'static str

Display name.

pub version: &'static str

Its version.

pub conformance: Conformance

How complete it is.

pub read: ReadFn

Reads a document.

pub read_inline: Option<ReadInlineFn>

Reads inline content, when the reader offers it.

pub struct guidedoc::Registry

The adapters a conversion may use. A plain value: build it once and share it.

Fields

pub readers: Vec<Reader>

Readers, by id.

pub renderers: Vec<Renderer>

Renderers, by id.

Implementations

impl Registry
pub fn find_reader(&self, id: &str) -> Option<&Reader>

Returns the reader with id.

pub fn find_renderer(&self, id: &str) -> Option<&Renderer>

Returns the renderer with id.

pub fn validate(&self) -> Result<(), Fail>

Checks that every adapter has an id and a version and that no id is registered twice. convert checks its registry the same way, so a bad registry fails with InvalidInput instead of the first match silently winning.

pub struct guidedoc::RenderContext<'a>

What a renderer works with for one render.

Fields

pub doc: Document<'a>

The document to render.

pub out: Emitter<'a>

Where the output goes.

pub options: &'a RenderOptions<'a>

The render options.

pub policy: Policy

The trust decisions.

pub limits: Limits

The bounds.

Implementations

impl<'a> RenderContext<'a>
pub fn new(doc: Document<'a>, out: Emitter<'a>, options: &'a RenderOptions<'a>, reports: &'a mut Reports) -> Self

Makes a context for rendering doc into out; the engine makes one per render, and renderer tests may make their own.

pub fn with_scratch(self, scratch: &'a mut Scratch) -> Self

Lets the context keep working state in scratch between renders (the engine passes the workspace’s); a context made with new alone keeps none.

pub fn take_scratch<T: Default + Send + 'static>(&mut self) -> T

Takes the renderer’s working state of type T (see Scratch::take): what an earlier render left, or T::default(). Clear what you use and give it back with put_scratch, so the next render reuses its storage.

pub fn put_scratch<T: Send + 'static>(&mut self, value: T)

Gives working state taken with take_scratch back; a context without a store drops it.

pub fn reports(&mut self) -> &mut Reports

Returns the reports of the render.

pub fn report(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg)

Reports message m at span.

Trait Implementations

impl fmt::Debug for RenderContext<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::Renderer

A renderer: a constant descriptor with a function and no state.

Fields

pub id: &'static str

Registry id («html»).

pub name: &'static str

Display name.

pub version: &'static str

Its version.

pub media_type: &'static str

The media type it writes («text/html»).

pub conformance: Conformance

How complete it is.

pub render: RenderFn

Renders a document.

pub struct guidedoc::AnchorExtra

The id of an element a renderer generates for a node:

  • an entry of a table of contents: owner is the Contents, item the Section;
  • a footnote of target-notes: owner is the directive, item the first target (or anonymous reference) with the URI it lists, number its footnote number;
  • the footnote reference target-notes adds after a reference: owner is the reference, item the directive, note the item of its footnote, number the same.

Fields

pub owner: NodeId

The node the element is generated for.

pub item: NodeId

The node it lists or notes.

pub note: NodeId

For a target-notes reference: the item of its footnote.

pub span: u32

Its id’s row in the table (extra_text).

pub number: i32

Its footnote number.

pub struct guidedoc::AnchorIds<'a>

The ids of one node, primary first; Anchors::anchor_ids makes it.

Trait Implementations

impl<'a> Iterator for AnchorIds<'a>
type Item = &'a str
fn next(&mut self) -> Option<&'a str>
pub struct guidedoc::Anchors

The anchor table of one document. Build it with build_anchors, or rebuild one with build_anchors_into to reuse its storage.

Implementations

impl Anchors
pub fn anchor_of(&self, id: NodeId) -> Option<&str>

Returns the primary id of node id, borrowed from the table.

pub fn anchor_ids(&self, id: NodeId) -> AnchorIds<'_>

Iterates every id of node id, the primary one first.

pub fn anchor_extras(&self, owner: NodeId) -> &[AnchorExtra]

Returns the ids generated for owner’s sake, in the order they were given.

pub fn extra_anchor(&self, owner: NodeId, item: NodeId) -> Option<&str>

Returns the id of the element generated for owner and item.

pub fn extras(&self) -> &[AnchorExtra]

Returns every generated element’s id record, sorted by owner and, for one owner, in the order the ids were given.

pub fn node_with_anchor(&self, anchor: &str) -> Option<NodeId>

Returns the node that carries the id anchor (with the anchor prefix, as anchor_ids gives it); None when no node carries it.

pub fn write_anchor_key(&self, out: &mut String, name: &str) -> bool

Writes into out the id build_anchors derives from name (the anchor prefix, then make_id), for node_with_anchor. Returns false, leaving out cleared, when the name gives no id.

pub fn extra_text(&self, e: &AnchorExtra) -> &str

Returns the id of a generated element.

pub struct guidedoc::Builder<'a>

Builds one snapshot for one stage (a read or a pass). It borrows the snapshot, the workspace’s reports, and a reusable open-node stack for the stage.

Fields

pub snap: &'a mut Snapshot

The snapshot being built. Readers may read it freely and edit what the builder has no method for; validation checks the result.

pub limits: Limits

The stage’s limits.

Implementations

impl<'a> Builder<'a>
pub fn new(snap: &'a mut Snapshot, reports: &'a mut Reports, open: &'a mut Vec<NodeId>, limits: Limits, root_span: SourceSpan) -> Builder<'a>

Starts a builder over snap, which it clears, and opens the root Document node at root_span. open is reusable storage for the open-node stack. The engine calls it for every read and pass; tests use it to drive a reader’s pieces. A failure to open the root poisons the builder (see status).

pub fn set_cancel(&mut self, cancel: Option<&'a dyn Fn() -> bool>)

Sets the probe polled while work is spent; true cancels the stage.

pub fn status(&self) -> Status

Returns Ok until the builder fails, then the failure’s status.

pub fn is_ok(&self) -> bool

Tells whether the builder has not failed.

pub fn need(&self) -> CapacityNeed

Returns the capacity a Capacity failure lacked.

pub fn work(&self) -> u64

Returns the work spent so far.

pub fn reports(&mut self) -> &mut Reports

Returns the reports the stage writes to.

pub fn report(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg)

Reports message m at span without failing.

pub fn document(&self) -> Document<'_>

Views the snapshot built so far, without sources.

pub fn fail(&mut self, d: Diagnostic) -> Fail

Reports d and poisons the builder with its status (the first failure wins); returns the failure to propagate.

pub fn capacity(&mut self, region: Region, minimum: u64) -> Fail

Poisons the builder with a Capacity failure of region, lacking minimum; nothing new is reported once it has failed.

pub fn spend(&mut self, steps: u64) -> Result<(), Fail>

Charges steps of work against Limits::max_work and polls cancellation periodically.

pub fn current(&self) -> Option<NodeId>

Returns the innermost open node; None once the root is closed.

pub fn current_kind(&self) -> NodeKind

Returns the kind of the innermost open node; Document when none is open.

pub fn open_nodes(&self) -> &[NodeId]

Returns the open nodes, outermost first.

pub fn begin_node(&mut self, kind: NodeKind, span: SourceSpan) -> Result<NodeId, Fail>

Opens a node of kind as the last child of the current node, to be closed with end_node. It fails, poisoning the builder, when the nesting is illegal (child_allowed), a limit is reached, or memory runs out.

pub fn end_node(&mut self, id: NodeId) -> Result<(), Fail>

Closes id, which must be the innermost open node, and records its subtree end; closing out of order poisons the builder.

pub fn with_node(&mut self, kind: NodeKind, span: SourceSpan, fill: impl FnOnce(&mut Self, NodeId) -> Result<(), Fail>) -> Result<NodeId, Fail>

Opens a node of kind, runs fill to add its attributes and children, and closes it: begin_node and end_node in one call that cannot forget the end.

pub fn build_text(&mut self, push: impl FnOnce(&mut Self) -> Result<(), Fail>) -> Result<Text, Fail>

Runs push, which writes into the text pool, and returns the text it wrote: text_open, the pushes, and text_close in one call.

pub fn add_leaf(&mut self, kind: NodeKind, span: SourceSpan, text: Text) -> Result<NodeId, Fail>

Adds a closed node of kind with pool text text and no children.

pub fn add_text_leaf(&mut self, kind: NodeKind, span: SourceSpan, s: &str) -> Result<NodeId, Fail>

Copies s into the pool and adds a leaf holding it.

pub fn add_text(&mut self, s: &str) -> Result<Text, Fail>

Copies s into the text pool and returns where it is.

pub fn text_open(&self) -> u32

Starts a run of pushed text: the offset text_close measures from.

pub fn text_used(&self) -> usize

Returns the bytes in the pool.

pub fn text_push(&mut self, s: &str) -> Result<(), Fail>

Copies s into the text pool.

pub fn text_push_bytes(&mut self, bytes: &[u8]) -> Result<(), Fail>

Copies raw bytes into the text pool; a run must end on a character boundary before the snapshot is validated.

pub fn text_push_byte(&mut self, c: u8) -> Result<(), Fail>

Copies one byte into the text pool.

pub fn text_push_char(&mut self, c: char) -> Result<(), Fail>

Copies c, UTF-8 encoded, into the text pool.

pub fn text_close(&self, start: u32) -> Text

Returns the text pushed since start (text_open); empty once failed.

pub fn text_rewind(&mut self, start: u32)

Drops text pushed since start; used when a tentative parse is abandoned.

pub fn pool_string(&self, t: Text) -> &str

Returns the text t of the pool; «» when out of range or not UTF-8.

pub fn set_text(&mut self, id: NodeId, t: Text)

Sets the text of node id; nothing happens once failed.

pub fn set_value(&mut self, id: NodeId, v: i32)

Sets the value of node id (a level, a count); nothing happens once failed.

pub fn add_flags(&mut self, id: NodeId, f: NodeFlags)

Adds flags to node id; nothing happens once failed.

pub fn set_span_end(&mut self, id: NodeId, end: u32)

Moves the end of node id’s span, as a reader learns where a construct ends.

pub fn set_kind(&mut self, id: NodeId, k: NodeKind)

Changes the kind of node id, as a pass does to a copy; validation checks it.

pub fn add_attribute(&mut self, id: NodeId, key: AttributeKey, value: Text) -> Result<(), Fail>

Adds an attribute to node id, which must be the most recently begun node, so each node’s attributes stay contiguous.

pub fn add_attribute_named(&mut self, id: NodeId, key: AttributeKey, value: Text, name: Text) -> Result<(), Fail>

Adds an attribute whose Custom key is the pool text name.

pub fn add_attribute_string(&mut self, id: NodeId, key: AttributeKey, value: &str) -> Result<(), Fail>

Copies value into the pool and adds it as attribute key of node id.

pub fn add_custom_attribute(&mut self, id: NodeId, name: &str, value: &str) -> Result<(), Fail>

Copies name and value into the pool and adds them as a Custom attribute.

pub fn set_list(&mut self, id: NodeId, info: ListInfo) -> Result<(), Fail>

Stores info as node id’s list payload.

Stores info as node id’s link payload and returns its row, for resolve_link.

pub fn set_cell(&mut self, id: NodeId, info: CellInfo) -> Result<(), Fail>

Stores info as node id’s cell payload.

Records the resolution of link row row (from set_link): its target, kind, and, when not empty, a new destination.

pub fn finish(&mut self) -> Result<(), Fail>

Closes the root. Every other node must already be closed.

pub fn unwrap_node(&mut self, id: NodeId) -> Result<(), Fail>

Removes a closed, non-root node and keeps its descendants in place, as when an RST section becomes the document title. Links resolved to later nodes follow them.

pub fn copy_subtree(&mut self, doc: Document<'_>, id: NodeId) -> Result<NodeId, Fail>

Copies a node of doc and its descendants, with their text, attributes, and payload rows, as the last child of the current node, and returns the copy of id. Copies are appended one per node, so the copy of a descendant d is copy + (d - id): a pass adjusts copies with set_value, set_text, add_flags, and set_kind.

pub fn copy_payload(&mut self, doc: Document<'_>, from: NodeId, to: NodeId) -> Result<(), Fail>

Copies node from’s list, cell, or link row of doc, with its texts, to node to of this builder.

Trait Implementations

impl fmt::Debug for Builder<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl TextSink for Builder<'_>

Writing into a builder appends to its text pool; a failure poisons the builder, which the next fallible call reports.

fn put_str(&mut self, s: &str)
pub struct guidedoc::Children<'a>

The children of a node, in order; Document::children makes it.

Trait Implementations

impl Iterator for Children<'_>
type Item = NodeId
fn next(&mut self) -> Option<NodeId>
pub struct guidedoc::Document<'a>

A read-only view of one document and its sources. It is Copy; pass it by value.

Implementations

impl<'a> Document<'a>
pub fn from_snapshot(snap: &'a Snapshot) -> Self

Views a snapshot without sources, such as the one a builder is filling (Builder::document); source accessors then return nothing.

pub fn snapshot(&self) -> &'a Snapshot

Returns the underlying tables.

pub fn node_count(&self) -> usize

Returns the number of nodes, the root included.

pub fn nodes(&self) -> &'a [Node]

Returns every node, in preorder.

pub fn node(&self, id: NodeId) -> &'a Node

Returns node id.

pub fn kind(&self, id: NodeId) -> NodeKind

Returns the kind of node id.

pub fn subtree_end(&self, id: NodeId) -> NodeId

Returns the id after the last descendant of node id.

pub fn text(&self, t: Text) -> &'a str

Returns the text t names; «» when it is out of range.

pub fn node_text(&self, id: NodeId) -> &'a str

Returns the text of node id.

pub fn has_children(&self, id: NodeId) -> bool

Tells whether node id has a child.

pub fn first_child(&self, id: NodeId) -> Option<NodeId>

Returns the first child of node id.

pub fn code_caption(&self, id: NodeId) -> Option<NodeId>

Returns a code block’s Caption child (its parsed Custom caption).

pub fn children(&self, id: NodeId) -> Children<'a>

Iterates the children of node id.

pub fn child_count(&self, id: NodeId) -> usize

Counts the children of node id, in time linear in their number.

pub fn parent_of(&self, id: NodeId) -> Option<NodeId>

Returns the parent of node id; None for the root. It scans backwards, so it is meant for diagnostics, not traversal.

pub fn attributes(&self, id: NodeId) -> &'a [Attribute]

Returns every attribute row of node id.

pub fn attribute(&self, id: NodeId, key: AttributeKey) -> Option<&'a str>

Returns the value of node id’s first attribute with key.

pub fn custom_attribute(&self, id: NodeId, name: &str) -> Option<&'a str>

Returns the value of node id’s Custom attribute named name.

pub fn has_class(&self, id: NodeId, class: &str) -> bool

Tells whether one of node id’s Class attributes (each a space-separated list) holds class.

pub fn list_info(&self, id: NodeId) -> ListInfo

Returns the list payload of node id, or a bullet list starting at 1.

Returns the link payload of node id, or None when it has none. Callers that treat a missing payload as unresolved write doc.link_info(id).unwrap_or(LinkInfo::UNRESOLVED).

pub fn cell_info(&self, id: NodeId) -> CellInfo

Returns the cell payload of node id, or a cell spanning one row and column.

pub fn sources(&self) -> &'a [SourceEntry]

Returns every source-table entry; 0 is the main source.

pub fn source_entry(&self, id: SourceId) -> Option<&'a SourceEntry>

Returns the source-table entry of id, or None for an unknown id.

pub fn source_str(&self, id: SourceId) -> &'a str

Returns the whole text of source id; «» for an unknown id.

pub fn source_text(&self, span: SourceSpan) -> &'a str

Returns the source text a span covers, or «» for an invalid span.

pub fn plain_text(&self, id: NodeId, out: &mut (impl TextSink + ?Sized))

Writes the concatenated text of a subtree, as alt text and ids use it: text, code, math, and raw inline nodes, and a space for each line break.

pub struct guidedoc::Emitter<'a>

A renderer’s output sink. The output is bytes so a renderer may copy text byte by byte; the engine checks the whole output is UTF-8 before returning it.

Implementations

impl<'a> Emitter<'a>
pub fn new(out: &'a mut Vec<u8>) -> Emitter<'a>

Makes a write-mode emitter appending to out, without a limit. Renderers and tests use it for side outputs (a dump, a highlighted fragment).

pub fn with_limit(out: &'a mut Vec<u8>, limit: usize) -> Emitter<'a>

Makes a write-mode emitter that stores at most limit bytes and counts the rest.

pub fn check() -> Emitter<'static>

Makes a check-mode emitter, which only counts.

pub fn set_source_map(&mut self, map: Option<&'a mut Vec<MapEntry>>)

Records source map entries into map (see emit_mark).

pub fn mode(&self) -> EmitMode

Returns the mode.

pub fn is_check(&self) -> bool

Tells whether this emitter only counts.

pub fn written(&self) -> usize

Returns the bytes written (stored or counted).

pub fn mapped(&self) -> usize

Returns the source map entries recorded.

pub fn emit_bytes(&mut self, bytes: &[u8])

Writes raw bytes.

pub fn written_since(&self, from: usize) -> &[u8]

The bytes stored since the output was from bytes long (a written value); empty in check mode or past the limit.

pub fn insert_bytes(&mut self, at: usize, bytes: &[u8])

Inserts bytes where the output was at bytes long (a written value at or after which everything is still stored), moving what follows. Renderers use it to add an attribute to a tag they already wrote. Counts only, like every write, in check mode or past the limit.

pub fn emit(&mut self, s: &str)

Writes s.

pub fn emit_byte(&mut self, c: u8)

Writes one byte.

pub fn emit_char(&mut self, c: char)

Writes c UTF-8 encoded.

pub fn emit_int(&mut self, value: i64)

Writes value in decimal.

pub fn emit_mark(&mut self, span: SourceSpan)

Records that output from here on originates at span.

Trait Implementations

impl fmt::Debug for Emitter<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl TextSink for Emitter<'_>
fn put_str(&mut self, s: &str)
pub struct guidedoc::MathCheck<'a>

How a formula is checked. Default checks inline math with no host macros.

Fields

pub alignment: bool

& and \\ are allowed outside an environment, because the renderer wraps the formula in an alignment (displayed math with line breaks).

pub line_breaks: bool

\\ alone is allowed outside an environment (displayed math).

pub macros: &'a [&'a str]

Commands the host defines, without the backslash (MathJax macros).

pub struct guidedoc::MathChecker

Checks the formulas of one document. It remembers the commands and environments the formulas define, since a definition holds for the rest of the page.

Implementations

impl MathChecker
pub fn new() -> MathChecker

Makes a checker that knows no definition yet.

pub fn check(&mut self, latex: &str, options: &MathCheck<'_>) -> Option<MathFault>

Returns the first fault of latex, or None when it has none or is longer than MAX_FORMULA_BYTES. Definitions in latex are remembered.

pub struct guidedoc::MathFault

The first fault of a formula.

Fields

pub message: Message

What is wrong; its hint template is {1}.

pub start: usize

The offending text starts at this byte of the formula.

pub end: usize

One past its last byte.

pub subject: String

The {0} argument: the command, or a description.

pub hint: String

The hint, with the suggested correction when there is one.

Implementations

impl MathFault
pub fn diagnostic(&self, span: SourceSpan) -> Diagnostic

The fault as a diagnostic at span.

pub struct guidedoc::MathMlDropped

What the filter left out of a formula it wrote.

Fields

pub count: usize

How many elements, attributes and declarations were dropped.

pub first: String

The first of them: an element as <name>, an attribute as its name.

pub first_element: String

The first dropped element, as <name>; empty when no element was dropped. A dropped element takes content out of the formula; a dropped attribute does not.

pub struct guidedoc::MathMlOptions<'a>

How the filter treats one formula. Default keeps the display attribute as it is written and counts every dropped attribute.

Fields

pub block: Option<bool>

Some(true) writes display="block" on the root, Some(false) writes none, whatever the input says; None keeps the input’s.

pub quiet_attributes: &'a [&'a str]

Attributes dropped without being counted (xmlns always is).

pub quiet_elements: &'a [&'a str]

Elements dropped, with all they contain, without being counted.

pub struct guidedoc::NameMap<V>

A map from &str names to values V, iterated in insertion order. Clearing it keeps its storage. Names are hashed with the standard library’s randomly keyed hasher, which resists collision attacks from hostile input.

Implementations

impl<V> NameMap<V>
pub fn new() -> Self

Makes an empty map; it allocates nothing until a name is inserted.

pub fn clear(&mut self)

Removes every entry, keeping the storage for the next names.

pub fn len(&self) -> usize

Returns the number of entries.

pub fn is_empty(&self) -> bool

Tells whether the map has no entry.

pub fn contains_key(&self, name: &str) -> bool

Tells whether name has an entry.

pub fn get(&self, name: &str) -> Option<&V>

Returns the value of name.

pub fn get_mut(&mut self, name: &str) -> Option<&mut V>

Returns the value of name, to change it.

pub fn insert(&mut self, name: &str, value: V) -> Option<V>

Sets the value of name and returns the value it replaces, if any.

pub fn get_or_insert_with(&mut self, name: &str, make: impl FnOnce() -> V) -> &mut V

Returns the value of name, inserting make() first when it has none.

pub fn iter(&self) -> impl Iterator<Item = (&str, &V)> + '_

Iterates the entries in insertion order.

pub fn values(&self) -> impl Iterator<Item = &V> + '_

Iterates the values in insertion order.

Trait Implementations

impl<V: fmt::Debug> fmt::Debug for NameMap<V>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl<V> Default for NameMap<V>
fn default() -> Self
pub struct guidedoc::Labels

Translated labels; a label without a translation falls back to English.

Implementations

impl Labels
pub fn set(&mut self, l: Label, text: impl Into<String>)

Sets the translation of l.

pub fn get(&self, l: Label) -> &str

Returns the translation of l, or «» when it has none.

Trait Implementations

impl Default for Labels
fn default() -> Labels

Every label empty: English throughout.

pub struct guidedoc::Limits

Bounds on the work and memory of one conversion. Reaching one is a Limit or Capacity result, never a panic. Default gives default_limits().

Fields

pub max_depth: usize

Nested blocks and inline markup.

pub max_nodes: usize

Nodes in one document.

pub max_work: u64

Reader and resolution steps (Builder::spend).

pub max_include_depth: usize

Nested includes.

pub max_included_bytes: usize

Bytes of included sources in one conversion.

pub max_expansion: usize

Substitution nesting.

pub stack_bytes: usize

Machine stack a recursive reader or renderer may use (StackGuard).

pub max_text_bytes: usize

Bytes in a snapshot’s text pool.

pub max_reports: usize

Diagnostics stored; later ones are counted as suppressed.

pub max_output_bytes: usize

Bytes of rendered output.

Trait Implementations

impl Default for Limits
fn default() -> Limits
pub struct guidedoc::MapEntry

Records that rendered output from offset on came from span.

Fields

pub offset: u32

Byte offset in the output.

pub span: SourceSpan

Where it came from.

pub struct guidedoc::Pass<'a>

A named transform run between reading and rendering (transform_document).

Fields

pub name: &'a str

Its name, for diagnostics.

pub run: &'a PassFn<'a>

What it does.

Trait Implementations

impl fmt::Debug for Pass<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::Policy

Trust decisions of one conversion. Default gives default_policy().

Fields

pub raw: ContentPolicy

Raw HTML, raw Typst, raw LaTeX.

pub unsafe_urls: ContentPolicy

javascript:, vbscript:, and non-image data: URLs.

pub math: ContentPolicy

Math the target cannot translate.

pub includes: bool

Whether include directives may request resources.

pub strict: bool

Warnings fail the conversion.

pub keep_documents_with_errors: bool

Keep a document whose errors are all content errors (content_error), as Docutils does below its halt level; renderers then report them as warnings.

Trait Implementations

impl Default for Policy
fn default() -> Policy
pub struct guidedoc::ReadExtension<'a>

A reader’s own settings (an rst::Settings, a commonmark::Settings, …): a borrowed value and its type name. read_extension makes one; a reader takes it back with ReadContext::reader_settings, which refuses settings of another type.

Fields

pub data: &'a dyn Any

The settings.

pub type_name: &'static str

Their type’s name, for diagnostics.

Implementations

impl<'a> ReadExtension<'a>
pub fn downcast<T: Any>(&self) -> Option<&'a T>

Returns the settings as &T, or None when they are of another type.

Trait Implementations

impl fmt::Debug for ReadExtension<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::ReadOptions<'a>

Options every reader understands. Default gives default_read_options().

Fields

pub promote_title: bool

RST: a lone top-level section becomes the title.

pub tab_width: usize

RST tab stops; zero means 8.

pub today: &'a str

RST date substitutions, e.g. «2026-09-29».

pub extension: Option<ReadExtension<'a>>

The reader’s own settings; None means its defaults.

pub check_math: bool

Check every LaTeX formula once after reading and warn about its first fault (math.*), whatever the output is.

pub math_macros: &'a [&'a str]

Math commands the host defines, without the backslash (MathJax macros); the math check takes them as known.

Trait Implementations

impl Default for ReadOptions<'_>
fn default() -> Self
pub struct guidedoc::RenderOptions<'a>

Options every renderer understands. Default is a standalone document in English.

Fields

pub standalone: bool

A complete document rather than a body fragment.

pub reference_profile: bool

CommonMark reference HTML, for conformance tests.

pub title: &'a str

Overrides the document’s own title.

pub language: &'a str

BCP 47 tag; «en» when empty.

pub stylesheet: &'a str

Standalone HTML: CSS emitted in a style element.

pub section_numbers: bool

Number sections.

pub anchor_prefix: &'a str

Prepended to every anchor, e.g. a document ID in a book (build_anchors).

HTML: a link to each heading, caption, and signature.

«¶» when empty.

pub secnumber_suffix: &'a str

After section numbers; «. « when empty.

pub highlighter: Option<&'a dyn Highlighter>

Highlights code blocks; None writes escaped code.

pub labels: Option<&'a Labels>

The words renderers write, translated; None is English.

pub math: MathStyle

How HTML writes math.

pub math_inline: [&'a str; 2]

HTML inline math delimiters with MathStyle::Sphinx; empty: \( \).

pub math_display: [&'a str; 2]

HTML displayed math delimiters with MathStyle::Sphinx; empty: \[ \].

pub math_writer: Option<&'a dyn MathWriter>

HTML: writes each formula as script-free markup (MathML); None, or a formula it refuses, writes the LaTeX as math says.

pub source_positions: Option<SourcePositions<'a>>

Preview source positions (see SourcePositions): HTML block elements carry data-gd-source="<source>:<start>-<end>", and Typst writes each block’s position as labelled metadata, so a preview maps a click back to the source. None writes no positions.

Trait Implementations

impl fmt::Debug for RenderOptions<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl Default for RenderOptions<'_>
fn default() -> Self
pub struct guidedoc::Request<'a>

A complete conversion request. Default (and default_request) give the documented defaults; change fields with struct-update syntax.

Fields

pub source: Source<'a>

The main source.

pub reader: &'a str

The reader’s id («rst»).

pub renderer: &'a str

The renderer’s id («html»).

pub read: ReadOptions<'a>

Read options.

pub render: RenderOptions<'a>

Render options.

pub policy: Policy

Trust decisions.

pub limits: Limits

Bounds.

pub passes: &'a [Pass<'a>]

Transforms between reading and rendering.

pub resources: Option<&'a dyn ResourceProvider>

Provides included files; None refuses includes.

pub cancel: Option<&'a dyn Fn() -> bool>

Polled during long work; true cancels.

pub source_map: bool

Whether renderers fill the workspace’s source map.

Trait Implementations

impl fmt::Debug for Request<'_>
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::Resource

A provided resource: its text, shared so a host can cache it, and a canonical name for cycle checks (usually an absolute path).

Fields

pub text: Arc<str>

UTF-8 text.

pub canonical: String

The name cycle checks compare.

pub struct guidedoc::Source<'a>

A named source text, borrowed for the conversion.

Fields

pub name: &'a str

Its name («intro.rst»).

pub text: &'a str

Its text.

pub struct guidedoc::PositionCache

Remembers each source’s offset, so a page asks SourcePositions::offset once per source rather than once per block.

Implementations

impl PositionCache
pub fn position(&mut self, doc: &Document<'_>, span: SourceSpan, positions: &SourcePositions<'_>) -> Option<String>

The position of span in doc as <source>:<start>-<end>, with the source named relative to positions.root. None for an empty span and for text a reader generated rather than read from a file, whose source name is empty or starts with < (such as <rst_epilog> or <autodoc mod.Obj>).

pub struct guidedoc::SourcePositions<'a>

How a preview writes block source positions.

Fields

pub root: &'a str

The folder source names are written relative to (a project’s source folder); empty: names as read.

pub offset: Option<fn(&str) -> usize>

The number of bytes a source file holds before the text it was read as, by source name: 3 for a file that starts with a byte order mark, which the readers drop. Positions add it, so they count the file’s own bytes. None: 0 for every source.

pub struct guidedoc::Diagnostic

One reported problem: a message, where it happened, and its arguments.

Fields

pub code: &'static str

Stable identifier.

pub severity: Severity

How serious it is.

pub status: Status

The status it fails with.

pub title: &'static str

Upper-case title.

pub message: &'static str

Explanation template.

pub hint: &'static str

How to fix it.

pub span: SourceSpan

Where it happened (zero when nowhere in particular).

pub args: [Arg; 2]

The {0} and {1} arguments.

Implementations

impl Diagnostic
pub fn message_of(&self) -> Message

Returns the static message the diagnostic was made from.

pub fn format_into(&self, template: &str, quote: &dyn Fn(SourceSpan) -> String, out: &mut String)

Writes template (the message or the hint) with its arguments substituted into out; quote gives the source text of a span argument.

pub fn formatted_message(&self) -> String

Returns the message with its arguments; spans are written as source:start..end.

pub fn formatted_hint(&self) -> String

Returns the hint with its arguments substituted.

Trait Implementations

impl fmt::Display for Diagnostic
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::Fail

The failure of a core call: a status, the capacity it lacked (for Capacity), and the diagnostic that explains it. Readers and passes propagate it with ?.

Fields

pub status: Status

Why it failed.

pub need: CapacityNeed

On Capacity, the region to enlarge.

pub diagnostic: Box<Diagnostic>

The primary diagnostic (boxed to keep Results small).

Implementations

impl Fail
pub fn new(status: Status) -> Fail

Makes a failure with status and no diagnostic.

pub fn from_diagnostic(d: Diagnostic) -> Fail

Makes a failure explained by d, with its status.

pub fn capacity(region: Region, minimum: u64, exact: bool) -> Fail

Makes a Capacity failure for region, lacking minimum (CORE_CAPACITY).

pub fn code(&self) -> &'static str

Returns the diagnostic’s code («core.capacity»); «» when it has none.

Trait Implementations

impl fmt::Display for Fail
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl std::error::Error for Fail
pub struct guidedoc::Message

A static description of one problem. Packages declare them as constants: const UNRESOLVED: Message = Message { code: "rst.reference.unresolved", .. }. Every message has a hint saying how to fix the problem (Elm style).

Fields

pub code: &'static str

Stable identifier («core.capacity»).

pub severity: Severity

How serious it is.

pub status: Status

The status it fails with, when it is an error.

pub title: &'static str

Upper-case title («NOT ENOUGH STORAGE»).

pub message: &'static str

Explanation; «{0}» and «{1}» name the arguments.

pub hint: &'static str

How to fix it.

pub struct guidedoc::Reports

The bounded report store of a workspace: every diagnostic in order up to Limits::max_reports, the first error kept by value even when the store is full, and counts of errors and warnings.

Implementations

impl Reports
pub fn new(max: usize) -> Reports

Makes an empty store holding at most max diagnostics.

pub fn clear(&mut self, max: usize)

Empties the store, keeping its storage, and sets its bound.

pub fn report(&mut self, d: Diagnostic)

Records d, unless muted. The first error is kept as the primary even when the store is full; a full store counts the diagnostic as suppressed.

pub fn message(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg)

Reports message m at span with its arguments, as report does.

pub fn items(&self) -> &[Diagnostic]

Returns every stored diagnostic, in order.

pub fn primary(&self) -> Option<&Diagnostic>

Returns the first error, if any.

pub fn first_problem(&self) -> Option<&Diagnostic>

Returns the primary error, or the first warning when there is none.

pub fn error_count(&self) -> usize

Returns the number of errors reported (stored or not).

pub fn warning_count(&self) -> usize

Returns the number of warnings reported (stored or not).

pub fn suppressed_count(&self) -> usize

Returns how many diagnostics a full store dropped.

pub fn is_truncated(&self) -> bool

Tells whether the store dropped diagnostics.

pub fn is_muted(&self) -> bool

Tells whether reporting is muted (a trial parse).

pub fn set_muted(&mut self, muted: bool) -> bool

Mutes or unmutes reporting; returns the previous setting, to restore.

pub fn fatal(&self) -> Status

Returns the first error that is not a content error (Ok when none).

pub struct guidedoc::Scratch

A store of reusable working state: for each Rust type, a pool of values that earlier conversions gave back. The workspace owns one; adapters reach it through ReadContext::take_scratch and RenderContext::take_scratch (and the matching put_scratch).

Taking a value out moves it, so it borrows nothing and the adapter keeps using its context freely. Nested conversions (a directive body parsed by the same reader) take further values of the same type; every value given back is kept, so each nesting level finds one next time. Once a type’s pool exists, taking and putting back do not allocate.

Implementations

impl Scratch
pub fn take<T: Default + Send + 'static>(&mut self) -> T

Takes a value of type T out of the store: one an earlier conversion gave back, or T::default() when there is none (the first conversion, or a nested one while outer ones hold the values). The value keeps whatever its last user left in it: clear what you use, keeping the capacity.

pub fn put<T: Send + 'static>(&mut self, value: T)

Gives value back for a later conversion to take.

pub fn len(&self) -> usize

Returns the number of types the store keeps values of.

pub fn is_empty(&self) -> bool

Tells whether the store keeps values of no type.

pub fn release(&mut self)

Drops every stored value, releasing its memory.

Trait Implementations

impl fmt::Debug for Scratch
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
pub struct guidedoc::Snapshot

The tables of one document. Readers and passes fill them through a Builder; its snap field gives direct access for the few edits the builder has no method for.

Fields

pub nodes: Vec<Node>

Nodes in preorder; nodes[0] is the Document.

pub attributes: Vec<Attribute>

Attribute rows; each node’s are contiguous.

pub lists: Vec<ListInfo>

List payload rows.

Link payload rows.

pub cells: Vec<CellInfo>

Cell payload rows.

pub text: Vec<u8>

The text pool. Bytes, so a reader can copy a source byte by byte; validation checks the pool is UTF-8 and every Text lies on character boundaries.

Implementations

impl Snapshot
pub fn clear(&mut self)

Empties every table, keeping their storage.

pub fn node(&self, id: NodeId) -> Option<&Node>

Returns node id, or None when out of range.

pub fn pool_str(&self, t: Text) -> &str

Returns the text t names, or «» when it is out of range or not UTF-8 (which happens only while a reader is half-way through pushing a character).

pub struct guidedoc::SourceEntry

One entry of a workspace’s source table. The main source’s text lives in the workspace (reused between conversions); included and added sources share theirs.

Fields

pub name: String

Its name (canonical, for included sources).

pub parent: SourceId

The including source; itself for the main source.

pub included_at: SourceSpan

The include directive, when included.

pub usage: SourceUse

How an included source is read.

pub struct guidedoc::StackGuard

Measures stack use from where it was made. A zero guard is never exhausted.

Implementations

impl StackGuard
pub fn used(&self) -> usize

Returns the stack used between the guard’s start and the caller’s frame.

pub fn is_exhausted(&self) -> bool

Tells whether the next frame would take the stack past the budget.

pub fn limit(&self) -> usize

Returns the budget in bytes.

pub fn diagnostic(&self, span: SourceSpan) -> Diagnostic

Returns the Limit diagnostic a guarded recursion reports at span.

pub struct guidedoc::SymbolTable

A bounded map from names to u32 values.

Implementations

impl SymbolTable
pub fn with_capacity(capacity: usize) -> SymbolTable

Makes a table for about capacity names. It holds at least 8 and rounds capacity up to a power of two, so the bound a caller sees is predictable.

pub fn insert(&mut self, key: &str, value: u32) -> Result<(), SymbolClash>

Inserts key with value. A duplicate or a full table leaves the table as it is.

pub fn get(&self, key: &str) -> Option<u32>

Returns the value stored for key.

pub fn set(&mut self, key: &str, value: u32) -> bool

Replaces the value of an existing key; false when it is absent.

pub fn count(&self) -> usize

Returns the number of names held.

pub fn clear(&mut self)

Empties the table, keeping its storage.

pub struct guidedoc::Attribute

One attribute row.

Fields

pub key: AttributeKey

The key.

pub name: Text

The key’s text when key is Custom.

pub value: Text

The value.

pub struct guidedoc::AttributeRange

A node’s attributes: rows first..first + count of the attribute table.

Fields

pub first: u32

First attribute row.

pub count: u32

Number of rows.

Implementations

impl AttributeRange
pub const fn range(self) -> std::ops::Range<usize>

Returns the rows as a range of indices.

pub struct guidedoc::CapacityNeed

What a Capacity failure needs: the region and the bytes or rows it lacked.

Fields

pub region: Region

The region that ran out.

pub minimum: u64

The least size that is needed (or the shortfall, when not exact).

pub exact: bool

Whether minimum is the exact size needed.

pub struct guidedoc::CellInfo

A Cell node’s payload row.

Fields

pub row_span: u16

Rows spanned (at least 1).

pub col_span: u16

Columns spanned (at least 1).

pub align: Align

Alignment.

Trait Implementations

impl Default for CellInfo
fn default() -> CellInfo

One row by one column, unaligned.

pub struct guidedoc::LineView<'s>

One line of a source as readers hand it to each other: its text without the line break, and the source offset of its first byte. Borrowed from the source text.

Fields

pub text: &'s str

The line’s text, without its break.

pub offset: u32

Offset of text in its source.

pub struct guidedoc::LinkInfo

A link-like node’s payload row.

Fields

pub destination: Text

URL, path, address, or project key.

pub title: Text

Link title.

pub name: Text

Normalized reference name, when named.

pub resolved: NodeId

The referent, meaningful only when kind is Internal.

pub kind: LinkKind

What the destination means.

Implementations

impl LinkInfo
pub const UNRESOLVED: LinkInfo

The row link_info stands in for a node without one: unresolved, no target.

Trait Implementations

impl Default for LinkInfo
fn default() -> LinkInfo

An External link with no text and resolved = INVALID_NODE.

pub struct guidedoc::ListInfo

A List node’s payload row.

Fields

pub style: ListStyle

Numbering style.

pub delimiter: u8

“.”, “)”, or “(“ for «(1)»; the bullet character for bullets.

pub start: i32

First number.

Trait Implementations

impl Default for ListInfo
fn default() -> ListInfo
pub struct guidedoc::Node

One node of the preorder node table.

Fields

pub kind: NodeKind

What the node is.

pub flags: NodeFlags

Its flags.

pub subtree_end: u32

The id after its last descendant.

pub value: i32

A small per-kind scalar (see docs/manual/internals/ast.rst), otherwise zero.

pub text: Text

Its text in the pool.

pub payload: u32

Its payload row, or NONE.

pub span: SourceSpan

Where it comes from.

pub attributes: AttributeRange

Its attribute rows.

pub struct guidedoc::NodeFlags(pub u8)

A set of NodeFlags in one byte (saved objects store the byte as it is).

Implementations

impl NodeFlags
pub const EMPTY: NodeFlags = NodeFlags(0)

The empty set.

pub const TIGHT: NodeFlags = NodeFlags::of(NodeFlag::Tight)

{Tight}.

pub const ANONYMOUS: NodeFlags = NodeFlags::of(NodeFlag::Anonymous)

{Anonymous}.

pub const AUTO: NodeFlags = NodeFlags::of(NodeFlag::Auto)

{Auto}.

pub const SYMBOL: NodeFlags = NodeFlags::of(NodeFlag::Symbol)

{Symbol}.

pub const LOCAL: NodeFlags = NodeFlags::of(NodeFlag::Local)

{Local}.

pub const HEADER: NodeFlags = NodeFlags::of(NodeFlag::Header)

{Header}.

pub const REFERENCED: NodeFlags = NodeFlags::of(NodeFlag::Referenced)

{Referenced}.

pub const GENERATED: NodeFlags = NodeFlags::of(NodeFlag::Generated)

{Generated}.

pub const fn of(flag: NodeFlag) -> NodeFlags

Returns the set holding only flag.

pub const fn has(self, flag: NodeFlag) -> bool

Tells whether flag is in the set.

pub const fn contains(self, other: NodeFlags) -> bool

Tells whether every flag of other is in the set.

pub const fn intersects(self, other: NodeFlags) -> bool

Tells whether the sets share a flag.

pub const fn is_empty(self) -> bool

Tells whether the set is empty.

pub fn insert(&mut self, other: NodeFlags)

Adds every flag of other.

pub fn remove(&mut self, other: NodeFlags)

Removes every flag of other.

Trait Implementations

impl BitOr for NodeFlags
type Output = NodeFlags
fn bitor(self, o: NodeFlags) -> NodeFlags
impl BitOrAssign for NodeFlags
fn bitor_assign(&mut self, o: NodeFlags)
impl From<NodeFlag> for NodeFlags
fn from(f: NodeFlag) -> NodeFlags
pub struct guidedoc::NodeId(pub u32)

A node’s index in its snapshot’s preorder node table. ROOT is the Document node.

Implementations

impl NodeId
pub const fn index(self) -> usize

Returns the id as a usize index into the node table.

pub fn from_index(index: usize) -> NodeId

Returns the id of node index; indices past u32::MAX give INVALID_NODE.

pub const fn plus(self, n: u32) -> NodeId

Returns the id n nodes after this one (saturating).

Trait Implementations

impl std::ops::Add<u32> for NodeId
type Output = NodeId
fn add(self, n: u32) -> NodeId
impl std::ops::Sub<u32> for NodeId
type Output = NodeId
fn sub(self, n: u32) -> NodeId
pub struct guidedoc::SourceId(pub u16)

An index into a workspace’s source table; 0 is the main source.

Implementations

impl SourceId
pub const MAIN: SourceId = SourceId(0)

The main source of a conversion.

pub const fn index(self) -> usize

Returns the id as a usize index into the source table.

pub struct guidedoc::SourceSpan

A half-open byte range in one source of the workspace’s source table.

Fields

pub source: SourceId

The source the bytes belong to.

pub start: u32

First byte.

pub end: u32

One past the last byte.

Implementations

impl SourceSpan
pub const fn new(source: SourceId, start: u32, end: u32) -> SourceSpan

Makes a span of source from start to end.

pub const fn is_zero(self) -> bool

Tells whether the span is the zero span (no source position).

pub struct guidedoc::Text

A byte range in a snapshot’s text pool.

Fields

pub start: u32

First byte in the pool.

pub len: u32

Length in bytes.

Implementations

impl Text
pub const fn range(self) -> std::ops::Range<usize>

Returns the range start..start + len, which Document::text slices.

pub const fn is_empty(self) -> bool

Tells whether the text is empty.

pub struct guidedoc::Workspace

One conversion’s storage. Use one workspace per thread; documents borrow it.

Implementations

impl Workspace
pub fn new() -> Workspace

Makes an empty workspace with default_limits(). It allocates nothing until used.

pub fn with_limits(limits: Limits) -> Workspace

Makes an empty workspace whose convert_text uses limits.

pub fn limits(&self) -> &Limits

Returns the limits convert_text uses.

pub fn document(&self) -> Option<Document<'_>>

Returns the current document: the last successful read, pass, or load, until the next conversion starts or the workspace is reset.

pub fn reports(&self) -> &Reports

Returns the reports of the current conversion, valid until the next one.

pub fn source_map(&self) -> &[MapEntry]

Returns the source map the last render recorded (Request::source_map).

pub fn sources(&self) -> &[SourceEntry]

Returns the source table of the current conversion.

pub fn source_str(&self, id: SourceId) -> &str

Returns the whole text of source id; «» for an unknown id.

pub fn source_text(&self, span: SourceSpan) -> &str

Returns the source text a span covers, or «» for an invalid span.

pub fn describe(&self, d: &Diagnostic) -> String

Returns a diagnostic’s message with its arguments, span arguments quoted from this workspace’s sources.

pub fn scratch(&mut self) -> &mut Scratch

Returns the working state readers and renderers keep between conversions.

pub fn reset(&mut self)

Forgets the document, sources, reports, and output, keeping their storage.

pub fn begin_read<'w>(&'w mut self, request: &'w Request<'w>) -> Result<ReadContext<'w>, Fail>

Starts a read of request’s source: a new conversion, the main source copied into the workspace, and a context whose builder has the root open. read_document uses it; reader tests use it to drive a reader’s pieces.

Trait Implementations

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

Enums

pub enum guidedoc::Conformance

How completely an adapter implements its format.

Variants

Planned

Not implemented yet.

Partial

Implemented with known gaps.

Conformant

Passes its conformance suite.

pub enum guidedoc::SourceText<'a>

The text of a source, as a reader holds it while it keeps building: borrowed for the main source, shared for included ones. It dereferences to &str.

Variants

Borrowed(&'a str)

The main source, borrowed from the workspace.

Shared(Arc<str>)

An included or added source.

Trait Implementations

impl Deref for SourceText<'_>
type Target = str
fn deref(&self) -> &str
pub enum guidedoc::EmitMode

What an emitter does with the bytes it is given.

Variants

Check

Count them only (check_render).

Write

Store them, up to the limit.

pub enum guidedoc::MathMlError

Why the filter wrote nothing.

Variants

TooLong

The text is longer than MAX_MATHML_BYTES.

TooDeep

Elements nest deeper than MAX_MATHML_DEPTH.

NoRoot

The text does not start with a math element, or has text around it.

Malformed

A tag is not closed, or an end tag closes another element.

Trait Implementations

impl fmt::Display for MathMlError
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
impl std::error::Error for MathMlError
pub enum guidedoc::MediaKind

The media an image path names.

Variants

Image

A picture.

Video

A video file.

Audio

An audio file.

pub enum guidedoc::ContentPolicy

What to do with content a policy governs.

Variants

Refuse

An error that names the construct and the policy.

Omit

A warning; the content is left out.

Allow

Trusted content is emitted.

pub enum guidedoc::Label

A word or phrase a renderer writes by itself; hosts translate them (Labels). Labels holding «%s» take a value (a version number); see split_label.

Variants

Attention
Caution
Danger
Error
Hint
Important
Note
Tip
Warning
SeeAlso
Todo
Contents
VersionAdded
VersionChanged
VersionDeprecated
VersionRemoved
SectionAuthor
ModuleAuthor
CodeAuthor
LinkHeading
LinkDefinition
LinkImage
LinkTable
LinkCode
LinkEquation
LinkTerm
Parameters
Variables
Raises
Returns
ReturnType
ReturnValues
TemplateParameters
Throws
Arguments
Availability
UnengravedScore

Implementations

impl Label
pub const ALL: [Label; LABEL_COUNT]

Every label, in declaration order (l as usize is its index here).

pub enum guidedoc::MathStyle

How HTML writes math for a script (MathJax, KaTeX) to typeset.

Variants

Plain

Class «math», the text in \( \) or \[ \], as Docutils writes it.

Sphinx

As Sphinx’s mathjax extension writes it.

pub enum guidedoc::PassOutcome

What a pass did.

Variants

Unchanged

It left the document as it is (costs nothing).

Rebuilt

It wrote a new document into the builder.

Failed

It failed; the previous document stays.

pub enum guidedoc::ResourceStatus

Why a resource provider did not provide a resource.

Variants

Missing

It does not exist.

Refused

The host refuses to provide it.

Limit

The host’s memory budget cannot hold it.

NotUtf8

It exists, but its text is not UTF-8.

pub enum guidedoc::Arg

A diagnostic argument: an integer, a quoted source span, or text. {0} and {1} in a message name the arguments.

Variants

None

No argument.

Int(i64)

An integer.

Span(SourceSpan)

The source text of a span, quoted.

Text(Cow<'static, str>)

Text: static, or owned when it was made at run time.

pub enum guidedoc::Severity

How serious a diagnostic is.

Variants

Note

Information only.

Warning

A problem that does not fail the conversion (unless strict).

Error

A problem that fails the conversion (unless kept by the policy).

pub enum guidedoc::SourceUse

How the reader uses an included source: parsed as markup (include), or shown as it is (literalinclude, a graph file). Hosts tell a document’s parts from files it only quotes, as Sphinx’s env.included does.

Variants

Parsed

Read as markup.

Literal

Shown as it is.

pub enum guidedoc::SymbolClash

Why SymbolTable::insert left the table unchanged.

Variants

Duplicate(u32)

The key was present, with this value.

Full

The table holds its capacity.

#[repr(i32)] pub enum guidedoc::AdmonitionKind

An Admonition node’s value.

Variants

Generic

The generic admonition directive.

Attention
Caution
Danger
Error
Hint
Important
Note
Tip
Warning
Seealso
Todo

Implementations

impl AdmonitionKind
pub const ALL: [AdmonitionKind; 12]

Every kind, in value order.

pub fn from_value(v: i32) -> Option<AdmonitionKind>

Returns the kind a node’s value holds, or None when out of range.

#[repr(u8)] pub enum guidedoc::Align

A cell’s alignment.

Variants

None
Left
Center
Right

Implementations

impl Align
pub const ALL: [Align; 4]

Every alignment, in declaration order.

#[repr(u8)] pub enum guidedoc::AttributeKey

An attribute’s key; Custom keys carry their name as text.

Variants

Custom

A key named by the attribute’s name text.

Class
Id
Name
Language
Alt
Width
Height
Scale
Align
Format
Title
Target
Start
Widths
Source

Implementations

impl AttributeKey
pub const ALL: [AttributeKey; 16]

Every key, in declaration order.

pub const fn name(self) -> &'static str

Returns the static name dumps write («class»); «custom» for Custom.

pub enum guidedoc::Content

What children a kind may have; see child_allowed.

Variants

Nothing

No children.

Blocks

Block children.

Inlines

Inline children.

Structure

Children of specific kinds only.

#[repr(i32)] pub enum guidedoc::DocumentReading

A Document node’s value: who read it, which decides the ids anchors give.

Variants

Docutils = 0

Read as Docutils reads it.

Sphinx = 1

Read by the Sphinx layer.

#[repr(u8)] pub enum guidedoc::LinkKind

What a link row’s destination means.

Variants

External

Destination is a URL or path.

Email

Destination is an address; HTML adds mailto:.

Internal

resolved is a node of this document.

Unresolved

The name awaits resolution.

Project

Destination is a project anchor key in another document.

Implementations

impl LinkKind
pub const ALL: [LinkKind; 5]

Every kind, in declaration order.

pub const fn name(self) -> &'static str

Returns the static name dumps write.

#[repr(u8)] pub enum guidedoc::ListStyle

A list’s numbering style.

Variants

Bullet
Arabic
LowerAlpha
UpperAlpha
LowerRoman
UpperRoman

Implementations

impl ListStyle
pub const ALL: [ListStyle; 6]

Every style, in declaration order.

pub const fn name(self) -> &'static str

Returns the static name dumps write («loweralpha»).

#[repr(u8)] pub enum guidedoc::NodeFlag

One node flag; NodeFlags holds a set of them.

Variants

Tight

List: items render without paragraph spacing.

Anonymous

Reference or Target: anonymous hyperlink.

Auto

Footnote or reference: auto-numbered.

Symbol

Footnote or reference: auto-symbol.

Local

Contents: only the enclosing section.

Header

Row or Cell: belongs to a header.

Referenced

Target or Footnote: something refers to it.

Generated

Created by resolution rather than markup.

Implementations

impl NodeFlag
pub const ALL: [NodeFlag; 8]

Every flag, in bit order.

pub const fn name(self) -> &'static str

Returns the static name dumps write («tight»).

#[repr(u8)] pub enum guidedoc::NodeKind

Every kind of node. docs/manual/internals/ast.rst documents each kind’s children and fields.

Variants

Document

The root.

Title
Subtitle
Section
Heading
Paragraph
BlockQuote
Attribution
List
ListItem
DefinitionList
DefinitionItem
Term
Classifier
Definition
FieldList
Field
FieldName
FieldBody
OptionList
OptionItem
OptionGroup
Option
OptionArgument
OptionDescription
LineBlock
Line
CodeBlock
Preformatted
DoctestBlock
MathBlock
RawBlock
ThematicBreak
Table
TableHead
TableBody
Row
Cell
Figure
Caption
Legend
Admonition
Topic
Sidebar
Rubric
Container
Compound
Footnote
Citation
Target
Comment
SubstitutionDefinition
Contents
Directive
Toctree
ToctreeEntry
Only
Glossary
VersionModified
Desc
DescSignature
DescContent
Hlist
ProductionList
Production
Index
Text
Emphasis
Strong
Code
Reference
Image
FootnoteReference
CitationReference
SubstitutionReference
InlineTarget
Math
RawInline
SoftBreak
HardBreak
Subscript
Superscript
TitleReference
Abbreviation
Role
Xref
DescName
DescAddname
DescAnnotation
DescParameterlist
DescParameter
DescOptional
DescReturns

Implementations

impl NodeKind
pub const ALL: [NodeKind; 94]

Every kind, in declaration order (ALL[k as usize] == k).

impl NodeKind
pub fn from_u8(v: u8) -> Option<NodeKind>

Returns the kind numbered v (its declaration order), or None.

pub enum guidedoc::Region

A storage region named by a capacity failure.

Variants

None

No region.

Nodes

The node table.

Text

The text pool.

Attributes

The attribute table.

Lists

The list payload table.

The link payload table.

Cells

The cell payload table.

Sources

The source table.

Scratch

Working memory of an adapter.

Reports

The report store.

Output

The rendered output.

SourceMap

The source map.

Implementations

impl Region
pub const fn name(self) -> &'static str

Returns the static name diagnostics write («nodes»).

pub enum guidedoc::Status

The outcome class of a stage. Ok is kept so builders can report their state.

Variants

Ok

Success.

InvalidInput

The input (or a document, request or registry) is invalid.

Unsupported

The input asks for something no adapter supports.

Policy

The policy refused something.

Capacity

Memory ran out; CapacityNeed says where.

Limit

A configured limit was reached.

Cancelled

The caller cancelled the conversion.

Internal

A bug in an adapter or the core.

Traits

pub trait guidedoc::Highlighter

Writes highlighted HTML for a code block. It belongs to the caller’s trust boundary. It returns false, having written nothing, to let the renderer write plain escaped code instead.

fn highlight(&self, language: &str, code: &str, out: &mut Emitter<'_>) -> bool

Writes code in language as highlighted HTML into out.

pub trait guidedoc::MathWriter

Writes one formula as markup that needs no script, such as MathML. It belongs to the caller’s trust boundary: what it writes goes into the page as it is. It returns false, having written nothing, to let the renderer write the formula’s LaTeX in its usual markup instead.

fn write_math(&self, latex: &str, display: bool, out: &mut Emitter<'_>) -> bool

Writes the formula latex (inline, or displayed when display) into out.

pub trait guidedoc::ResourceProvider

Provides included files. It belongs to the caller’s trust boundary and may allocate. The core passes the name of the requesting source and the name as written.

fn provide(&self, from: &str, name: &str) -> Result<Resource, ResourceStatus>

Returns the resource name that source from asks for.

pub trait guidedoc::TextSink

Something text can be written into: a String, a byte buffer, a builder’s text pool, or an emitter. Helpers such as normalize_label and make_id write into any of them, so callers reuse their own buffers instead of receiving fresh strings.

fn put_str(&mut self, s: &str)

Appends s.

fn put_char(&mut self, c: char)

Appends one character.

Implementors

impl TextSink for Builder<'_>
impl TextSink for Emitter<'_>
impl TextSink for String
impl TextSink for Vec<u8>

Functions

pub fn guidedoc::validate_registry(r: &Registry) -> Result<(), Fail>

Validates a registry: fails when an adapter lacks metadata or is registered twice.

pub fn guidedoc::build_anchors(doc: Document<'_>, options: &RenderOptions<'_>, headings: bool) -> Anchors

Builds the anchor table of doc with the options” anchor prefix. headings gives ids to headings outside sections (every profile but CommonMark’s reference one).

pub fn guidedoc::build_anchors_into(a: &mut Anchors, doc: Document<'_>, options: &RenderOptions<'_>, headings: bool)

Rebuilds a as the anchor table of doc, as build_anchors builds one, reusing the table’s storage: a renderer that keeps its table between conversions does not allocate once the table fits the largest document.

pub fn guidedoc::id_fold(r: char) -> &'static str

Returns the ASCII transliteration make_id gives a lowercase character («é» gives «e», «²» gives «2»), or «» when it has none.

pub fn guidedoc::make_id(out: &mut (impl TextSink + ?Sized), name: &str)

Turns a name into an identifier matching [a-z](-?[a-z0-9]+)*: letters are lowercased and transliterated to ASCII (id_fold), every other run of characters becomes one hyphen, and leading digits and hyphens are dropped, as published Sphinx URLs expect. It may write nothing.

pub fn guidedoc::write_id(out: &mut (impl TextSink + ?Sized), name: &str)

Lowercases letters, keeps letters and digits, and joins every other run of characters with one hyphen. It names documents and chapters, whose names may start with digits (they get «id-« before them); make_id names anchors. A name without a letter or digit gives «section».

pub fn guidedoc::contents_scope(doc: Document<'_>, contents: NodeId) -> (NodeId, NodeId, usize)

Returns the range of nodes a table of contents lists and the number of sections around that range.

pub fn guidedoc::check_render(ws: &mut Workspace, renderer: &Renderer, request: &Request<'_>) -> Result<usize, Fail>

Runs the renderer without storing output and returns the exact output size; every support problem is reported as a render would report it.

pub fn guidedoc::convert<'w>(ws: &'w mut Workspace, registry: &Registry, request: &Request<'_>) -> Result<&'w str, Fail>

Reads, transforms (when the request has passes), and renders one source, with the adapters registry names. It checks the registry first. The output borrows the workspace until its next conversion; on failure the workspace’s reports explain it and the Fail carries the primary diagnostic.

pub fn guidedoc::convert_text<'w>(ws: &'w mut Workspace, registry: &Registry, reader: &str, renderer: &str, text: &str) -> Result<&'w str, Fail>

Converts text with default_request and the workspace’s limits: the one-call path. guidedoc::convert_text(&mut ws, &registry, "commonmark", "html", text).

pub fn guidedoc::read_document<'w>(ws: &'w mut Workspace, reader: &Reader, request: &Request<'_>) -> Result<Document<'w>, Fail>

Reads the request’s source with reader into a new conversion and validates it. The document borrows the workspace until its next mutable use. Content errors fail it unless Policy::keep_documents_with_errors; strict policy fails on warnings.

pub fn guidedoc::render_document<'w>(ws: &'w mut Workspace, renderer: &Renderer, request: &Request<'_>) -> Result<&'w str, Fail>

Renders the current document into the workspace’s output and returns it, valid until the next conversion. Output past Limits::max_output_bytes fails with Capacity and the exact size needed; strict policy fails on warnings.

pub fn guidedoc::transform_document<'w>(ws: &'w mut Workspace, passes: &[Pass<'_>], limits: &Limits) -> Result<Document<'w>, Fail>

Runs passes in order on the current document. A rebuilding pass writes the other snapshot, which is validated before it becomes current; when a pass fails, the previous document stays current. Passes keep the read’s error policy.

pub fn guidedoc::dump_to_string(doc: Document<'_>) -> String

Returns the outline of doc as a new string (for tests and debugging).

pub fn guidedoc::dump_tree(doc: Document<'_>, out: &mut (impl TextSink + ?Sized))

Writes the outline of doc into out, one node per line, indented two spaces per level.

pub fn guidedoc::admonition_name(k: AdmonitionKind) -> &'static str

Returns the static class name of an admonition kind («note», «tip»).

pub fn guidedoc::child_allowed(parent: NodeKind, child: NodeKind) -> bool

States the legal parent-child pairs. Builders and validation share it.

pub fn guidedoc::content_model(k: NodeKind) -> Content

Tells what children nodes of kind k may have; see child_allowed. Exhaustive, as payload_of is.

pub fn guidedoc::kind_name(k: NodeKind) -> &'static str

Returns the static name of a node kind, as dumps and diagnostics write it.

pub fn guidedoc::check_math(latex: &str, options: &MathCheck<'_>) -> Option<MathFault>

Checks one formula alone. See MathChecker::check.

pub fn guidedoc::is_math_command(name: &str) -> bool

Tells whether name (without the backslash) is a LaTeX math command we know.

pub fn guidedoc::is_math_environment(name: &str) -> bool

Tells whether name is a LaTeX math environment we know.

pub fn guidedoc::suggest_math_command(name: &str) -> Option<&'static str>

The known command closest to the misspelled name, if one is close.

pub fn guidedoc::suggest_math_environment(name: &str) -> Option<&'static str>

The known environment closest to the misspelled name, if one is close.

pub fn guidedoc::filter_mathml(input: &str, options: &MathMlOptions<'_>, out: &mut String) -> Result<MathMlDropped, MathMlError>

Appends the MathML Core form of input (one math element) to out and returns what it left out. It borrows both for the call. On failure out is as it was.

pub fn guidedoc::media_kind(path: &str) -> MediaKind

Reads a path’s extension, ignoring case, a query, and a fragment.

pub fn guidedoc::nfd_first(s: &str) -> char

Returns the first character of s in NFD, as Sphinx takes an index entry’s letter: unicodedata.normalize("NFD", s[0])[0]. An empty string gives U+FFFD.

pub fn guidedoc::normalize_nfd(s: &str) -> Cow<'_, str>

Returns s in Normalization Form D, borrowing it when it is already in that form (all ASCII, the common case for index keys).

pub fn guidedoc::normalize_nfd_into(out: &mut String, s: &str)

Appends s in Normalization Form D to out, reusing out’s storage. Combining marks of a run are collected in a small buffer and reordered there.

pub fn guidedoc::load_object<'w>(ws: &'w mut Workspace, bytes: &[u8], limits: &Limits) -> Result<Document<'w>, Fail>

Rebuilds a document from bytes write_object wrote, as a new conversion of ws, and validates it. The bytes are copied; they need not outlive the document.

pub fn guidedoc::write_object(doc: Document<'_>, out: &mut Vec<u8>)

Appends doc, with its sources, to out as object bytes.

pub fn guidedoc::admonition_label<'a>(options: &RenderOptions<'a>, k: AdmonitionKind) -> &'a str

Returns the title of an admonition kind; «» for a generic admonition.

pub fn guidedoc::default_limits() -> Limits

Returns the documented limits: depth 256, a million nodes, 2^32 work steps, includes 8 deep and 32 MiB in total, expansion 16, 512 KiB of stack, 256 MiB of text, 256 reports, and 1 GiB of output.

pub fn guidedoc::default_policy() -> Policy

Returns the safe policy: raw content, unsafe URLs, and untranslatable math refused; includes may be requested.

pub fn guidedoc::default_read_options() -> ReadOptions<'static>

Returns the read options: title promotion on, tab width 8, no reader settings, the math check on.

pub fn guidedoc::default_request<'a>(name: &'a str, text: &'a str, reader: &'a str, renderer: &'a str) -> Request<'a>

Returns a complete request with the documented defaults: default read options, a standalone render, default_policy(), default_limits(), no passes, no resource provider, no cancellation. It borrows its arguments.

pub fn guidedoc::is_mathml(doc: Document<'_>, id: crate::NodeId) -> bool

Tells whether the formula id is written as MathML, not LaTeX. The HTML renderer passes its MathML Core through a filter; renderers that cannot typeset MathML show its source.

pub fn guidedoc::label<'a>(options: &RenderOptions<'a>, l: Label) -> &'a str

Returns a label in the render’s language, or in English when it has none.

pub fn guidedoc::read_extension<T: Any>(settings: &T) -> ReadExtension<'_>

Wraps borrowed reader settings with their type; they must outlive the read.

pub fn guidedoc::split_label(s: &str) -> (&str, &str)

Splits a label at its «%s»: the text before and after the value.

pub fn guidedoc::trusted_policy() -> Policy

Returns the policy for conformance tests and content the caller wrote: everything allowed.

pub fn guidedoc::unengraved_score(doc: Document<'_>, id: crate::NodeId, options: &RenderOptions<'_>) -> Option<String>

For a code block that stands for an unread score file, the sentence a renderer shows in its place, in the rendering language; None for any other node. Renderers call this instead of knowing the directive’s attributes.

pub fn guidedoc::relative_source(name: &str, root: &str) -> String

name relative to the folder root, with / separators. Only Windows names use \ as a separator, so only there is it turned into /.

pub fn guidedoc::arg_int(v: i64) -> Arg

Makes an integer argument.

pub fn guidedoc::arg_span(s: SourceSpan) -> Arg

Makes an argument that quotes the source text of s.

pub fn guidedoc::arg_static(s: &'static str) -> Arg

Makes an argument of static text; it copies nothing.

pub fn guidedoc::arg_text(s: &str) -> Arg

Makes an argument of text that does not live long enough to borrow; it copies s.

pub fn guidedoc::content_error(status: Status) -> bool

Tells whether an error’s status describes the content (an unknown directive, a bad option, an unresolved reference, content refused by policy) rather than a tree that cannot be used. Policy::keep_documents_with_errors keeps documents whose errors are all content errors.

pub fn guidedoc::diagnostic(m: Message, span: SourceSpan, a: Arg, b: Arg) -> Diagnostic

Builds a diagnostic from message m at span with up to two arguments.

pub fn guidedoc::kept_message(policy: &Policy, m: Message) -> Message

Returns m as a renderer reports it: a content error becomes a warning when the policy keeps documents with errors, so the page is still written.

pub fn guidedoc::recycle<T, U>(mut buffer: Vec<T>) -> Vec<U>

Empties buffer and returns its storage as a vector of another type of the same size and alignment. A reader keeps a buffer of borrowed values (Vec<Line<'s>>, borrowing one conversion’s source) in its scratch as Vec<Line<'static>>, and turns it back with recycle in the next conversion: the standard library collects an emptied vector into one of a same-sized type in place, without allocating.

pub fn guidedoc::stack_diagnostic(g: &StackGuard, span: SourceSpan) -> Diagnostic

Returns the diagnostic a guard’s recursion reports.

pub fn guidedoc::stack_exhausted(g: &StackGuard) -> bool

Tells whether the guard’s budget is spent.

pub fn guidedoc::stack_guard(limits: &Limits) -> StackGuard

Starts measuring at the caller’s frame, with the limits” stack budget.

pub fn guidedoc::check_utf8(source: SourceId, bytes: &[u8]) -> Result<&str, Fail>

Checks that bytes are UTF-8 and returns them as text; otherwise a CORE_UTF8 failure whose span (in source source) covers the first bad byte. Hosts call it on file contents before building a Request.

pub fn guidedoc::decode_last_rune(s: &str, end: usize) -> (char, usize)

Decodes the character ending at byte end of s, as decode_rune does.

pub fn guidedoc::decode_rune(s: &str, i: usize) -> (char, usize)

Decodes the character starting at byte i of s, with its width. A position that is not a character boundary decodes as U+FFFD with width 1, so a scan always moves forward; past the end gives U+FFFD with width 0.

pub fn guidedoc::fold_rune(r: char) -> ([char; 3], usize)

Applies Unicode full case folding (statuses C and F) to r: up to three characters, and how many.

pub fn guidedoc::is_ascii_alnum(c: u8) -> bool

Tells whether c is an ASCII letter or digit.

pub fn guidedoc::is_ascii_digit(c: u8) -> bool

Tells whether c is an ASCII digit.

pub fn guidedoc::is_ascii_punct(c: u8) -> bool

Tells whether c is ASCII punctuation, as CommonMark defines it.

pub fn guidedoc::is_ascii_space(c: u8) -> bool

Tells whether c is ASCII white space: space, tab, LF, CR, FF, or VT.

pub fn guidedoc::is_decimal_digit(r: char) -> bool

Tells whether r is a decimal digit (general category Nd).

pub fn guidedoc::is_letter(r: char) -> bool

Tells whether r is a letter (general category L).

pub fn guidedoc::is_unicode_punctuation(r: char) -> bool

Tells whether r is punctuation as CommonMark 0.31 defines it: general categories P and S.

pub fn guidedoc::is_unicode_whitespace(r: char) -> bool

Tells whether r is white space as CommonMark defines it: Zs characters, tab, LF, FF, and CR.

pub fn guidedoc::line_bounds(text: &str, offset: usize) -> (usize, usize)

Returns the byte range of the line holding offset, without its break.

pub fn guidedoc::line_column(text: &str, offset: usize) -> (usize, usize)

Converts a byte offset into a 1-based line and byte column.

pub fn guidedoc::normalize_label(out: &mut (impl TextSink + ?Sized), label: &str)

Writes the case-folded label with runs of white space collapsed to one space and the ends trimmed. CommonMark labels and RST names are normalized this way.

pub fn guidedoc::to_lower(r: char) -> char

Returns the simple lowercase mapping of r (one character); characters whose full mapping has several characters keep the first one, which is the simple mapping for every such character (U+0130 gives “i”).

pub fn guidedoc::offset_in(outer: &str, inner: &str) -> Option<usize>

Returns where inner starts in outer when inner is a slice of outer’s bytes, and None otherwise (an empty inner included). It compares addresses only.

pub fn guidedoc::validate(snap: &Snapshot, source_lengths: &[usize], limits: &Limits) -> Result<(), Fail>

Checks a finished snapshot. source_lengths[i] is the byte length of source i. It allocates its own working stack; the engine uses validate_with and a reused one.

Type Aliases

pub type guidedoc::ReadFn = fn(&mut ReadContext<'_>) -> Result<(), Fail>

Reads ctx.source into ctx.b.

pub type guidedoc::ReadInlineFn = fn(&mut ReadContext<'_>, SourceSpan) -> Result<(), Fail>

Parses a span of ctx.source as inline content of the builder’s open node, as a translated message is parsed. It neither resolves references nor reports unresolved ones. span.source must be ctx.source.

pub type guidedoc::RenderFn = fn(&mut RenderContext<'_>) -> Result<(), Fail>

Writes ctx.doc with ctx.out.

pub type guidedoc::PassFn<'a> = dyn Fn(Document<'_>, &mut Builder<'_>) -> PassOutcome + 'a

The function of a pass: it reads an immutable document and may rebuild it.

Constants

pub const guidedoc::BUILDER_OPEN: u32 = u32::MAX - 1

The subtree end of a node that is still open.

pub const guidedoc::MATH_ALIGNMENT: Message

& or \\ where nothing aligns.

pub const guidedoc::MATH_ARGUMENT: Message

A command followed by fewer arguments than it takes.

pub const guidedoc::MATH_BRACE: Message

A { without its }, or a } without its {.

pub const guidedoc::MATH_COMMAND_UNKNOWN: Message

A command no LaTeX math vocabulary we know has.

pub const guidedoc::MATH_DELIMITER: Message

A \left without its \right, or a \right without its \left.

pub const guidedoc::MATH_ENVIRONMENT_MISMATCH: Message

An \end that names another environment than the open one.

pub const guidedoc::MATH_ENVIRONMENT_UNCLOSED: Message

A \begin without its \end, or an \end without its \begin.

pub const guidedoc::MATH_ENVIRONMENT_UNKNOWN: Message

An environment no LaTeX math vocabulary we know has.

pub const guidedoc::MAX_FORMULA_BYTES: usize = 64 << 10

The longest formula checked, in bytes. A longer one is left alone.

pub const guidedoc::MATHML_ATTRIBUTES: [&str; 26]

The attributes the filter keeps, on any kept element.

pub const guidedoc::MATHML_ELEMENTS: [&str; 28]

The elements the filter keeps: MathML Core’s presentation elements.

pub const guidedoc::MAX_MATHML_BYTES: usize = 256 << 10

The longest MathML text the filter reads, in bytes.

pub const guidedoc::MAX_MATHML_DEPTH: usize = 128

The deepest element nesting the filter follows.

pub const guidedoc::ENGLISH_LABELS: [&str; LABEL_COUNT]

The labels in English (Sphinx’s msgids), indexed by Label as usize.

pub const guidedoc::LABEL_COUNT: usize = 37

The number of labels.

pub const guidedoc::MATH_NOTATION_ATTRIBUTE: &str = "notation"

The custom attribute of a formula that is not written in LaTeX. Its only value is mathml: the node’s text is then one MathML math element (see is_mathml).

pub const guidedoc::SCORE_FILE_ATTRIBUTE: &str = "lilypond-file"

The custom attribute a lilypond directive with a file argument carries. The reader never opens the file; the project builder engraves it.

pub const guidedoc::CORE_CAPACITY: Message

A region ran out of memory; {0} names it and {1} the shortfall.

pub const guidedoc::CORE_DEPTH: Message

Nesting past Limits::max_depth.

pub const guidedoc::CORE_NODES: Message

More than Limits::max_nodes nodes.

pub const guidedoc::CORE_STACK: Message

Recursion past Limits::stack_bytes.

pub const guidedoc::CORE_UNHANDLED_KIND: Message

A renderer routed a node to a handler that does not write it.

pub const guidedoc::CORE_UTF8: Message

A bytes source is not UTF-8.

pub const guidedoc::CORE_WORK: Message

More than Limits::max_work steps.

pub const guidedoc::INCLUDE_MISSING: Message

The provider has no such resource. Readers report it too (literalinclude).

pub const guidedoc::DEFAULT_STACK_BYTES: usize = 512 << 10

The stack a reader or renderer may use when Limits::stack_bytes is 0. With STACK_RESERVE it fits a 1 MiB thread, the smallest default thread stack of the supported platforms (Windows).

pub const guidedoc::STACK_RESERVE: usize = 128 << 10

The stack a conversion needs below its deepest guard. Debug builds have larger frames, so a debug build should run conversions on a thread with more room.

pub const guidedoc::INVALID_NODE: NodeId = NodeId(u32::MAX)

«No node»: the table value for a node that is absent.

pub const guidedoc::NONE: u32 = u32::MAX

«No row»: a node’s payload when it has none.

pub const guidedoc::ROOT: NodeId = NodeId(0)

The root Document node of every snapshot.

pub const guidedoc::VERSION: &str = env!("CARGO_PKG_VERSION")

The engine’s version: the project version every crate inherits.

pub const guidedoc::SCHEMA_VERSION: u32 = 1

Counts the incompatible changes to documents saved as objects (write_object).