guidedoc ======== .. rust:crate:: guidedoc :synopsis: 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. 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. .. code-block:: rust 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, ®istry, "commonmark", "html", "# Hi\n"); assert_eq!(failure.map_err(|f| f.code()), Err("core.reader.unknown")); .. rubric:: Structs .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: pub b: Builder<'a> The builder of the document being read. .. rust:field:: pub source: SourceId The source to read. .. rust:field:: pub options: &'a ReadOptions<'a> The read options. .. rust:field:: pub policy: Policy The trust decisions. .. rust:field:: pub limits: Limits The bounds. .. rubric:: Implementations .. rust:impl:: impl<'a> ReadContext<'a> :noindex: :for: ReadContext<'a> .. rust:method:: pub fn reports(&mut self) -> &mut Reports Returns the reports of the read. .. rust:method:: pub fn take_scratch(&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. .. rust:method:: pub fn put_scratch(&mut self, value: T) Gives working state taken with ``take_scratch`` back to the workspace. .. rust:method:: 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``. .. rust:method:: 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. .. rust:method:: pub fn source_entry(&self, id: SourceId) -> Option<&SourceEntry> Returns the source-table entry of ``id`` (its name, parent, and include span). .. rust:method:: pub fn source_count(&self) -> usize Returns the number of sources in the table. .. rust:method:: pub fn source_text(&self, span: SourceSpan) -> &str Returns the source text a span covers, or "" for an invalid span. .. rust:method:: pub fn document(&self) -> Document<'_> Views the document built so far with its sources. .. rust:method:: pub fn reader_settings(&mut self) -> Result, 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``. .. rust:method:: 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``. .. rust:impl:: impl ReadContext<'_> :noindex: :for: ReadContext<'_> .. rust:method:: pub fn include_source(&mut self, from: SourceId, name: &str, span: SourceSpan, usage: SourceUse) -> Option 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. .. rust:method:: pub fn add_source(&mut self, name: &str, text: &str) -> Option 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. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for ReadContext<'_> :noindex: :for: ReadContext<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct Reader A reader: a constant descriptor with functions and no state. .. rubric:: Fields .. rust:field:: pub id: &'static str Registry id ("rst"). .. rust:field:: pub name: &'static str Display name. .. rust:field:: pub version: &'static str Its version. .. rust:field:: pub conformance: Conformance How complete it is. .. rust:field:: pub read: ReadFn Reads a document. .. rust:field:: pub read_inline: Option Reads inline content, when the reader offers it. .. rust:struct:: pub struct Registry The adapters a conversion may use. A plain value: build it once and share it. .. rubric:: Fields .. rust:field:: pub readers: Vec Readers, by id. .. rust:field:: pub renderers: Vec Renderers, by id. .. rubric:: Implementations .. rust:impl:: impl Registry :noindex: :for: Registry .. rust:method:: pub fn find_reader(&self, id: &str) -> Option<&Reader> Returns the reader with ``id``. .. rust:method:: pub fn find_renderer(&self, id: &str) -> Option<&Renderer> Returns the renderer with ``id``. .. rust:method:: 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. .. rust:struct:: pub struct RenderContext<'a> What a renderer works with for one render. .. rubric:: Fields .. rust:field:: pub doc: Document<'a> The document to render. .. rust:field:: pub out: Emitter<'a> Where the output goes. .. rust:field:: pub options: &'a RenderOptions<'a> The render options. .. rust:field:: pub policy: Policy The trust decisions. .. rust:field:: pub limits: Limits The bounds. .. rubric:: Implementations .. rust:impl:: impl<'a> RenderContext<'a> :noindex: :for: RenderContext<'a> .. rust:method:: 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. .. rust:method:: 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. .. rust:method:: pub fn take_scratch(&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. .. rust:method:: pub fn put_scratch(&mut self, value: T) Gives working state taken with ``take_scratch`` back; a context without a store drops it. .. rust:method:: pub fn reports(&mut self) -> &mut Reports Returns the reports of the render. .. rust:method:: pub fn report(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg) Reports message ``m`` at ``span``. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for RenderContext<'_> :noindex: :for: RenderContext<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct Renderer A renderer: a constant descriptor with a function and no state. .. rubric:: Fields .. rust:field:: pub id: &'static str Registry id ("html"). .. rust:field:: pub name: &'static str Display name. .. rust:field:: pub version: &'static str Its version. .. rust:field:: pub media_type: &'static str The media type it writes ("text/html"). .. rust:field:: pub conformance: Conformance How complete it is. .. rust:field:: pub render: RenderFn Renders a document. .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: pub owner: NodeId The node the element is generated for. .. rust:field:: pub item: NodeId The node it lists or notes. .. rust:field:: pub note: NodeId For a target-notes reference: the item of its footnote. .. rust:field:: pub span: u32 Its id's row in the table (``extra_text``). .. rust:field:: pub number: i32 Its footnote number. .. rust:struct:: pub struct AnchorIds<'a> The ids of one node, primary first; ``Anchors::anchor_ids`` makes it. .. rubric:: Trait Implementations .. rust:impl:: impl<'a> Iterator for AnchorIds<'a> :noindex: :for: AnchorIds<'a> :trait: Iterator .. rust:associatedtype:: type Item = &'a str :noindex: .. rust:method:: fn next(&mut self) -> Option<&'a str> :noindex: .. rust:struct:: pub struct Anchors The anchor table of one document. Build it with ``build_anchors``, or rebuild one with ``build_anchors_into`` to reuse its storage. .. rubric:: Implementations .. rust:impl:: impl Anchors :noindex: :for: Anchors .. rust:method:: pub fn anchor_of(&self, id: NodeId) -> Option<&str> Returns the primary id of node ``id``, borrowed from the table. .. rust:method:: pub fn anchor_ids(&self, id: NodeId) -> AnchorIds<'_> Iterates every id of node ``id``, the primary one first. .. rust:method:: pub fn anchor_extras(&self, owner: NodeId) -> &[AnchorExtra] Returns the ids generated for ``owner``'s sake, in the order they were given. .. rust:method:: pub fn extra_anchor(&self, owner: NodeId, item: NodeId) -> Option<&str> Returns the id of the element generated for ``owner`` and ``item``. .. rust:method:: 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. .. rust:method:: pub fn node_with_anchor(&self, anchor: &str) -> Option Returns the node that carries the id ``anchor`` (with the anchor prefix, as ``anchor_ids`` gives it); ``None`` when no node carries it. .. rust:method:: 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. .. rust:method:: pub fn extra_text(&self, e: &AnchorExtra) -> &str Returns the id of a generated element. .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: 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. .. rust:field:: pub limits: Limits The stage's limits. .. rubric:: Implementations .. rust:impl:: impl<'a> Builder<'a> :noindex: :for: Builder<'a> .. rust:method:: pub fn new(snap: &'a mut Snapshot, reports: &'a mut Reports, open: &'a mut Vec, 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``). .. rust:method:: pub fn set_cancel(&mut self, cancel: Option<&'a dyn Fn() -> bool>) Sets the probe polled while work is spent; true cancels the stage. .. rust:method:: pub fn status(&self) -> Status Returns ``Ok`` until the builder fails, then the failure's status. .. rust:method:: pub fn is_ok(&self) -> bool Tells whether the builder has not failed. .. rust:method:: pub fn need(&self) -> CapacityNeed Returns the capacity a ``Capacity`` failure lacked. .. rust:method:: pub fn work(&self) -> u64 Returns the work spent so far. .. rust:method:: pub fn reports(&mut self) -> &mut Reports Returns the reports the stage writes to. .. rust:method:: pub fn report(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg) Reports message ``m`` at ``span`` without failing. .. rust:method:: pub fn document(&self) -> Document<'_> Views the snapshot built so far, without sources. .. rust:method:: 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. .. rust:method:: 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. .. rust:method:: pub fn spend(&mut self, steps: u64) -> Result<(), Fail> Charges ``steps`` of work against ``Limits::max_work`` and polls cancellation periodically. .. rust:method:: pub fn current(&self) -> Option Returns the innermost open node; ``None`` once the root is closed. .. rust:method:: pub fn current_kind(&self) -> NodeKind Returns the kind of the innermost open node; Document when none is open. .. rust:method:: pub fn open_nodes(&self) -> &[NodeId] Returns the open nodes, outermost first. .. rust:method:: pub fn begin_node(&mut self, kind: NodeKind, span: SourceSpan) -> Result 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. .. rust:method:: 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. .. rust:method:: pub fn with_node(&mut self, kind: NodeKind, span: SourceSpan, fill: impl FnOnce(&mut Self, NodeId) -> Result<(), Fail>) -> Result 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. .. rust:method:: pub fn build_text(&mut self, push: impl FnOnce(&mut Self) -> Result<(), Fail>) -> Result Runs ``push``, which writes into the text pool, and returns the text it wrote: ``text_open``, the pushes, and ``text_close`` in one call. .. rust:method:: pub fn add_leaf(&mut self, kind: NodeKind, span: SourceSpan, text: Text) -> Result Adds a closed node of ``kind`` with pool text ``text`` and no children. .. rust:method:: pub fn add_text_leaf(&mut self, kind: NodeKind, span: SourceSpan, s: &str) -> Result Copies ``s`` into the pool and adds a leaf holding it. .. rust:method:: pub fn add_text(&mut self, s: &str) -> Result Copies ``s`` into the text pool and returns where it is. .. rust:method:: pub fn text_open(&self) -> u32 Starts a run of pushed text: the offset ``text_close`` measures from. .. rust:method:: pub fn text_used(&self) -> usize Returns the bytes in the pool. .. rust:method:: pub fn text_push(&mut self, s: &str) -> Result<(), Fail> Copies ``s`` into the text pool. .. rust:method:: 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. .. rust:method:: pub fn text_push_byte(&mut self, c: u8) -> Result<(), Fail> Copies one byte into the text pool. .. rust:method:: pub fn text_push_char(&mut self, c: char) -> Result<(), Fail> Copies ``c``, UTF-8 encoded, into the text pool. .. rust:method:: pub fn text_close(&self, start: u32) -> Text Returns the text pushed since ``start`` (``text_open``); empty once failed. .. rust:method:: pub fn text_rewind(&mut self, start: u32) Drops text pushed since ``start``; used when a tentative parse is abandoned. .. rust:method:: pub fn pool_string(&self, t: Text) -> &str Returns the text ``t`` of the pool; "" when out of range or not UTF-8. .. rust:method:: pub fn set_text(&mut self, id: NodeId, t: Text) Sets the text of node ``id``; nothing happens once failed. .. rust:method:: pub fn set_value(&mut self, id: NodeId, v: i32) Sets the value of node ``id`` (a level, a count); nothing happens once failed. .. rust:method:: pub fn add_flags(&mut self, id: NodeId, f: NodeFlags) Adds flags to node ``id``; nothing happens once failed. .. rust:method:: 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. .. rust:method:: 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. .. rust:method:: 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. .. rust:method:: 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``. .. rust:method:: 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``. .. rust:method:: 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. .. rust:method:: pub fn set_list(&mut self, id: NodeId, info: ListInfo) -> Result<(), Fail> Stores ``info`` as node ``id``'s list payload. .. rust:method:: pub fn set_link(&mut self, id: NodeId, info: LinkInfo) -> Result Stores ``info`` as node ``id``'s link payload and returns its row, for ``resolve_link``. .. rust:method:: pub fn set_cell(&mut self, id: NodeId, info: CellInfo) -> Result<(), Fail> Stores ``info`` as node ``id``'s cell payload. .. rust:method:: pub fn resolve_link(&mut self, row: u32, target: NodeId, kind: LinkKind, destination: Text) Records the resolution of link row ``row`` (from ``set_link``): its target, kind, and, when not empty, a new destination. .. rust:method:: pub fn finish(&mut self) -> Result<(), Fail> Closes the root. Every other node must already be closed. .. rust:method:: 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. .. rust:method:: pub fn copy_subtree(&mut self, doc: Document<'_>, id: NodeId) -> Result 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``. .. rust:method:: 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. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Builder<'_> :noindex: :for: Builder<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:impl:: impl TextSink for Builder<'_> :noindex: :for: Builder<'_> :trait: TextSink Writing into a builder appends to its text pool; a failure poisons the builder, which the next fallible call reports. .. rust:method:: fn put_str(&mut self, s: &str) :noindex: .. rust:struct:: pub struct Children<'a> The children of a node, in order; ``Document::children`` makes it. .. rubric:: Trait Implementations .. rust:impl:: impl Iterator for Children<'_> :noindex: :for: Children<'_> :trait: Iterator .. rust:associatedtype:: type Item = NodeId :noindex: .. rust:method:: fn next(&mut self) -> Option :noindex: .. rust:struct:: pub struct Document<'a> A read-only view of one document and its sources. It is ``Copy``; pass it by value. .. rubric:: Implementations .. rust:impl:: impl<'a> Document<'a> :noindex: :for: Document<'a> .. rust:method:: 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. .. rust:method:: pub fn snapshot(&self) -> &'a Snapshot Returns the underlying tables. .. rust:method:: pub fn node_count(&self) -> usize Returns the number of nodes, the root included. .. rust:method:: pub fn nodes(&self) -> &'a [Node] Returns every node, in preorder. .. rust:method:: pub fn node(&self, id: NodeId) -> &'a Node Returns node ``id``. .. rust:method:: pub fn kind(&self, id: NodeId) -> NodeKind Returns the kind of node ``id``. .. rust:method:: pub fn subtree_end(&self, id: NodeId) -> NodeId Returns the id after the last descendant of node ``id``. .. rust:method:: pub fn text(&self, t: Text) -> &'a str Returns the text ``t`` names; "" when it is out of range. .. rust:method:: pub fn node_text(&self, id: NodeId) -> &'a str Returns the text of node ``id``. .. rust:method:: pub fn has_children(&self, id: NodeId) -> bool Tells whether node ``id`` has a child. .. rust:method:: pub fn first_child(&self, id: NodeId) -> Option Returns the first child of node ``id``. .. rust:method:: pub fn code_caption(&self, id: NodeId) -> Option Returns a code block's Caption child (its parsed Custom ``caption``). .. rust:method:: pub fn children(&self, id: NodeId) -> Children<'a> Iterates the children of node ``id``. .. rust:method:: pub fn child_count(&self, id: NodeId) -> usize Counts the children of node ``id``, in time linear in their number. .. rust:method:: pub fn parent_of(&self, id: NodeId) -> Option Returns the parent of node ``id``; ``None`` for the root. It scans backwards, so it is meant for diagnostics, not traversal. .. rust:method:: pub fn attributes(&self, id: NodeId) -> &'a [Attribute] Returns every attribute row of node ``id``. .. rust:method:: pub fn attribute(&self, id: NodeId, key: AttributeKey) -> Option<&'a str> Returns the value of node ``id``'s first attribute with ``key``. .. rust:method:: pub fn custom_attribute(&self, id: NodeId, name: &str) -> Option<&'a str> Returns the value of node ``id``'s Custom attribute named ``name``. .. rust:method:: 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``. .. rust:method:: pub fn list_info(&self, id: NodeId) -> ListInfo Returns the list payload of node ``id``, or a bullet list starting at 1. .. rust:method:: pub fn link_info(&self, id: NodeId) -> Option 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)``. .. rust:method:: pub fn cell_info(&self, id: NodeId) -> CellInfo Returns the cell payload of node ``id``, or a cell spanning one row and column. .. rust:method:: pub fn sources(&self) -> &'a [SourceEntry] Returns every source-table entry; 0 is the main source. .. rust:method:: pub fn source_entry(&self, id: SourceId) -> Option<&'a SourceEntry> Returns the source-table entry of ``id``, or ``None`` for an unknown id. .. rust:method:: pub fn source_str(&self, id: SourceId) -> &'a str Returns the whole text of source ``id``; "" for an unknown id. .. rust:method:: pub fn source_text(&self, span: SourceSpan) -> &'a str Returns the source text a span covers, or "" for an invalid span. .. rust:method:: 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. .. rust:struct:: pub struct 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. .. rubric:: Implementations .. rust:impl:: impl<'a> Emitter<'a> :noindex: :for: Emitter<'a> .. rust:method:: pub fn new(out: &'a mut Vec) -> 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). .. rust:method:: pub fn with_limit(out: &'a mut Vec, limit: usize) -> Emitter<'a> Makes a write-mode emitter that stores at most ``limit`` bytes and counts the rest. .. rust:method:: pub fn check() -> Emitter<'static> Makes a check-mode emitter, which only counts. .. rust:method:: pub fn set_source_map(&mut self, map: Option<&'a mut Vec>) Records source map entries into ``map`` (see ``emit_mark``). .. rust:method:: pub fn mode(&self) -> EmitMode Returns the mode. .. rust:method:: pub fn is_check(&self) -> bool Tells whether this emitter only counts. .. rust:method:: pub fn written(&self) -> usize Returns the bytes written (stored or counted). .. rust:method:: pub fn mapped(&self) -> usize Returns the source map entries recorded. .. rust:method:: pub fn emit_bytes(&mut self, bytes: &[u8]) Writes raw bytes. .. rust:method:: 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. .. rust:method:: 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. .. rust:method:: pub fn emit(&mut self, s: &str) Writes ``s``. .. rust:method:: pub fn emit_byte(&mut self, c: u8) Writes one byte. .. rust:method:: pub fn emit_char(&mut self, c: char) Writes ``c`` UTF-8 encoded. .. rust:method:: pub fn emit_int(&mut self, value: i64) Writes ``value`` in decimal. .. rust:method:: pub fn emit_mark(&mut self, span: SourceSpan) Records that output from here on originates at ``span``. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Emitter<'_> :noindex: :for: Emitter<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:impl:: impl TextSink for Emitter<'_> :noindex: :for: Emitter<'_> :trait: TextSink .. rust:method:: fn put_str(&mut self, s: &str) :noindex: .. rust:struct:: pub struct MathCheck<'a> How a formula is checked. ``Default`` checks inline math with no host macros. .. rubric:: Fields .. rust:field:: pub alignment: bool ``&`` and ``\\`` are allowed outside an environment, because the renderer wraps the formula in an alignment (displayed math with line breaks). .. rust:field:: pub line_breaks: bool ``\\`` alone is allowed outside an environment (displayed math). .. rust:field:: pub macros: &'a [&'a str] Commands the host defines, without the backslash (MathJax ``macros``). .. rust:struct:: pub struct 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. .. rubric:: Implementations .. rust:impl:: impl MathChecker :noindex: :for: MathChecker .. rust:method:: pub fn new() -> MathChecker Makes a checker that knows no definition yet. .. rust:method:: pub fn check(&mut self, latex: &str, options: &MathCheck<'_>) -> Option Returns the first fault of ``latex``, or None when it has none or is longer than :rust:const:`MAX_FORMULA_BYTES `. Definitions in ``latex`` are remembered. .. rust:struct:: pub struct MathFault The first fault of a formula. .. rubric:: Fields .. rust:field:: pub message: Message What is wrong; its hint template is ``{1}``. .. rust:field:: pub start: usize The offending text starts at this byte of the formula. .. rust:field:: pub end: usize One past its last byte. .. rust:field:: pub subject: String The ``{0}`` argument: the command, or a description. .. rust:field:: pub hint: String The hint, with the suggested correction when there is one. .. rubric:: Implementations .. rust:impl:: impl MathFault :noindex: :for: MathFault .. rust:method:: pub fn diagnostic(&self, span: SourceSpan) -> Diagnostic The fault as a diagnostic at ``span``. .. rust:struct:: pub struct MathMlDropped What the filter left out of a formula it wrote. .. rubric:: Fields .. rust:field:: pub count: usize How many elements, attributes and declarations were dropped. .. rust:field:: pub first: String The first of them: an element as ````, an attribute as its name. .. rust:field:: pub first_element: String The first dropped element, as ````; empty when no element was dropped. A dropped element takes content out of the formula; a dropped attribute does not. .. rust:struct:: pub struct MathMlOptions<'a> How the filter treats one formula. ``Default`` keeps the ``display`` attribute as it is written and counts every dropped attribute. .. rubric:: Fields .. rust:field:: pub block: Option ``Some(true)`` writes ``display="block"`` on the root, ``Some(false)`` writes none, whatever the input says; ``None`` keeps the input's. .. rust:field:: pub quiet_attributes: &'a [&'a str] Attributes dropped without being counted (``xmlns`` always is). .. rust:field:: pub quiet_elements: &'a [&'a str] Elements dropped, with all they contain, without being counted. .. rust:struct:: pub struct NameMap 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. .. rubric:: Implementations .. rust:impl:: impl NameMap :noindex: :for: NameMap .. rust:method:: pub fn new() -> Self Makes an empty map; it allocates nothing until a name is inserted. .. rust:method:: pub fn clear(&mut self) Removes every entry, keeping the storage for the next names. .. rust:method:: pub fn len(&self) -> usize Returns the number of entries. .. rust:method:: pub fn is_empty(&self) -> bool Tells whether the map has no entry. .. rust:method:: pub fn contains_key(&self, name: &str) -> bool Tells whether ``name`` has an entry. .. rust:method:: pub fn get(&self, name: &str) -> Option<&V> Returns the value of ``name``. .. rust:method:: pub fn get_mut(&mut self, name: &str) -> Option<&mut V> Returns the value of ``name``, to change it. .. rust:method:: pub fn insert(&mut self, name: &str, value: V) -> Option Sets the value of ``name`` and returns the value it replaces, if any. .. rust:method:: 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. .. rust:method:: pub fn iter(&self) -> impl Iterator + '_ Iterates the entries in insertion order. .. rust:method:: pub fn values(&self) -> impl Iterator + '_ Iterates the values in insertion order. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for NameMap :noindex: :for: NameMap :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:impl:: impl Default for NameMap :noindex: :for: NameMap :trait: Default .. rust:method:: fn default() -> Self :noindex: .. rust:struct:: pub struct Labels Translated labels; a label without a translation falls back to English. .. rubric:: Implementations .. rust:impl:: impl Labels :noindex: :for: Labels .. rust:method:: pub fn set(&mut self, l: Label, text: impl Into) Sets the translation of ``l``. .. rust:method:: pub fn get(&self, l: Label) -> &str Returns the translation of ``l``, or "" when it has none. .. rubric:: Trait Implementations .. rust:impl:: impl Default for Labels :noindex: :for: Labels :trait: Default .. rust:method:: fn default() -> Labels :noindex: Every label empty: English throughout. .. rust:struct:: pub struct 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()``. .. rubric:: Fields .. rust:field:: pub max_depth: usize Nested blocks and inline markup. .. rust:field:: pub max_nodes: usize Nodes in one document. .. rust:field:: pub max_work: u64 Reader and resolution steps (``Builder::spend``). .. rust:field:: pub max_include_depth: usize Nested includes. .. rust:field:: pub max_included_bytes: usize Bytes of included sources in one conversion. .. rust:field:: pub max_expansion: usize Substitution nesting. .. rust:field:: pub stack_bytes: usize Machine stack a recursive reader or renderer may use (``StackGuard``). .. rust:field:: pub max_text_bytes: usize Bytes in a snapshot's text pool. .. rust:field:: pub max_reports: usize Diagnostics stored; later ones are counted as suppressed. .. rust:field:: pub max_output_bytes: usize Bytes of rendered output. .. rubric:: Trait Implementations .. rust:impl:: impl Default for Limits :noindex: :for: Limits :trait: Default .. rust:method:: fn default() -> Limits :noindex: .. rust:struct:: pub struct MapEntry Records that rendered output from ``offset`` on came from ``span``. .. rubric:: Fields .. rust:field:: pub offset: u32 Byte offset in the output. .. rust:field:: pub span: SourceSpan Where it came from. .. rust:struct:: pub struct Pass<'a> A named transform run between reading and rendering (``transform_document``). .. rubric:: Fields .. rust:field:: pub name: &'a str Its name, for diagnostics. .. rust:field:: pub run: &'a PassFn<'a> What it does. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Pass<'_> :noindex: :for: Pass<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct Policy Trust decisions of one conversion. ``Default`` gives ``default_policy()``. .. rubric:: Fields .. rust:field:: pub raw: ContentPolicy Raw HTML, raw Typst, raw LaTeX. .. rust:field:: pub unsafe_urls: ContentPolicy ``javascript:``, ``vbscript:``, and non-image ``data:`` URLs. .. rust:field:: pub math: ContentPolicy Math the target cannot translate. .. rust:field:: pub includes: bool Whether include directives may request resources. .. rust:field:: pub strict: bool Warnings fail the conversion. .. rust:field:: 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. .. rubric:: Trait Implementations .. rust:impl:: impl Default for Policy :noindex: :for: Policy :trait: Default .. rust:method:: fn default() -> Policy :noindex: .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: pub data: &'a dyn Any The settings. .. rust:field:: pub type_name: &'static str Their type's name, for diagnostics. .. rubric:: Implementations .. rust:impl:: impl<'a> ReadExtension<'a> :noindex: :for: ReadExtension<'a> .. rust:method:: pub fn downcast(&self) -> Option<&'a T> Returns the settings as ``&T``, or ``None`` when they are of another type. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for ReadExtension<'_> :noindex: :for: ReadExtension<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct ReadOptions<'a> Options every reader understands. ``Default`` gives ``default_read_options()``. .. rubric:: Fields .. rust:field:: pub promote_title: bool RST: a lone top-level section becomes the title. .. rust:field:: pub tab_width: usize RST tab stops; zero means 8. .. rust:field:: pub today: &'a str RST date substitutions, e.g. "2026-09-29". .. rust:field:: pub extension: Option> The reader's own settings; ``None`` means its defaults. .. rust:field:: pub check_math: bool Check every LaTeX formula once after reading and warn about its first fault (``math.*``), whatever the output is. .. rust:field:: pub math_macros: &'a [&'a str] Math commands the host defines, without the backslash (MathJax ``macros``); the math check takes them as known. .. rubric:: Trait Implementations .. rust:impl:: impl Default for ReadOptions<'_> :noindex: :for: ReadOptions<'_> :trait: Default .. rust:method:: fn default() -> Self :noindex: .. rust:struct:: pub struct RenderOptions<'a> Options every renderer understands. ``Default`` is a standalone document in English. .. rubric:: Fields .. rust:field:: pub standalone: bool A complete document rather than a body fragment. .. rust:field:: pub reference_profile: bool CommonMark reference HTML, for conformance tests. .. rust:field:: pub title: &'a str Overrides the document's own title. .. rust:field:: pub language: &'a str BCP 47 tag; "en" when empty. .. rust:field:: pub stylesheet: &'a str Standalone HTML: CSS emitted in a style element. .. rust:field:: pub section_numbers: bool Number sections. .. rust:field:: pub anchor_prefix: &'a str Prepended to every anchor, e.g. a document ID in a book (``build_anchors``). .. rust:field:: pub permalinks: bool HTML: a link to each heading, caption, and signature. .. rust:field:: pub permalink_icon: &'a str "¶" when empty. .. rust:field:: pub secnumber_suffix: &'a str After section numbers; ". " when empty. .. rust:field:: pub highlighter: Option<&'a dyn Highlighter> Highlights code blocks; ``None`` writes escaped code. .. rust:field:: pub labels: Option<&'a Labels> The words renderers write, translated; ``None`` is English. .. rust:field:: pub math: MathStyle How HTML writes math. .. rust:field:: pub math_inline: [&'a str; 2] HTML inline math delimiters with ``MathStyle::Sphinx``; empty: ``\(`` ``\)``. .. rust:field:: pub math_display: [&'a str; 2] HTML displayed math delimiters with ``MathStyle::Sphinx``; empty: ``\[`` ``\]``. .. rust:field:: 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. .. rust:field:: pub source_positions: Option> Preview source positions (see :rust:struct:`SourcePositions `): HTML block elements carry ``data-gd-source=":-"``, and Typst writes each block's position as labelled metadata, so a preview maps a click back to the source. ``None`` writes no positions. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for RenderOptions<'_> :noindex: :for: RenderOptions<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:impl:: impl Default for RenderOptions<'_> :noindex: :for: RenderOptions<'_> :trait: Default .. rust:method:: fn default() -> Self :noindex: .. rust:struct:: pub struct Request<'a> A complete conversion request. ``Default`` (and ``default_request``) give the documented defaults; change fields with struct-update syntax. .. rubric:: Fields .. rust:field:: pub source: Source<'a> The main source. .. rust:field:: pub reader: &'a str The reader's id ("rst"). .. rust:field:: pub renderer: &'a str The renderer's id ("html"). .. rust:field:: pub read: ReadOptions<'a> Read options. .. rust:field:: pub render: RenderOptions<'a> Render options. .. rust:field:: pub policy: Policy Trust decisions. .. rust:field:: pub limits: Limits Bounds. .. rust:field:: pub passes: &'a [Pass<'a>] Transforms between reading and rendering. .. rust:field:: pub resources: Option<&'a dyn ResourceProvider> Provides included files; ``None`` refuses includes. .. rust:field:: pub cancel: Option<&'a dyn Fn() -> bool> Polled during long work; true cancels. .. rust:field:: pub source_map: bool Whether renderers fill the workspace's source map. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Request<'_> :noindex: :for: Request<'_> :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct Resource A provided resource: its text, shared so a host can cache it, and a canonical name for cycle checks (usually an absolute path). .. rubric:: Fields .. rust:field:: pub text: Arc UTF-8 text. .. rust:field:: pub canonical: String The name cycle checks compare. .. rust:struct:: pub struct Source<'a> A named source text, borrowed for the conversion. .. rubric:: Fields .. rust:field:: pub name: &'a str Its name ("intro.rst"). .. rust:field:: pub text: &'a str Its text. .. rust:struct:: pub struct PositionCache Remembers each source's offset, so a page asks ``SourcePositions::offset`` once per source rather than once per block. .. rubric:: Implementations .. rust:impl:: impl PositionCache :noindex: :for: PositionCache .. rust:method:: pub fn position(&mut self, doc: &Document<'_>, span: SourceSpan, positions: &SourcePositions<'_>) -> Option The position of ``span`` in ``doc`` as ``:-``, 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 ```` or ````). .. rust:struct:: pub struct SourcePositions<'a> How a preview writes block source positions. .. rubric:: Fields .. rust:field:: pub root: &'a str The folder source names are written relative to (a project's source folder); empty: names as read. .. rust:field:: pub offset: Option 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. .. rust:struct:: pub struct Diagnostic One reported problem: a message, where it happened, and its arguments. .. rubric:: Fields .. rust:field:: pub code: &'static str Stable identifier. .. rust:field:: pub severity: Severity How serious it is. .. rust:field:: pub status: Status The status it fails with. .. rust:field:: pub title: &'static str Upper-case title. .. rust:field:: pub message: &'static str Explanation template. .. rust:field:: pub hint: &'static str How to fix it. .. rust:field:: pub span: SourceSpan Where it happened (zero when nowhere in particular). .. rust:field:: pub args: [Arg; 2] The ``{0}`` and ``{1}`` arguments. .. rubric:: Implementations .. rust:impl:: impl Diagnostic :noindex: :for: Diagnostic .. rust:method:: pub fn message_of(&self) -> Message Returns the static message the diagnostic was made from. .. rust:method:: 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. .. rust:method:: pub fn formatted_message(&self) -> String Returns the message with its arguments; spans are written as ``source:start..end``. .. rust:method:: pub fn formatted_hint(&self) -> String Returns the hint with its arguments substituted. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Display for Diagnostic :noindex: :for: Diagnostic :trait: fmt::Display .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct 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 ``?``. .. rubric:: Fields .. rust:field:: pub status: Status Why it failed. .. rust:field:: pub need: CapacityNeed On ``Capacity``, the region to enlarge. .. rust:field:: pub diagnostic: Box The primary diagnostic (boxed to keep ``Result``\ s small). .. rubric:: Implementations .. rust:impl:: impl Fail :noindex: :for: Fail .. rust:method:: pub fn new(status: Status) -> Fail Makes a failure with ``status`` and no diagnostic. .. rust:method:: pub fn from_diagnostic(d: Diagnostic) -> Fail Makes a failure explained by ``d``, with its status. .. rust:method:: pub fn capacity(region: Region, minimum: u64, exact: bool) -> Fail Makes a ``Capacity`` failure for ``region``, lacking ``minimum`` (CORE_CAPACITY). .. rust:method:: pub fn code(&self) -> &'static str Returns the diagnostic's code ("core.capacity"); "" when it has none. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Display for Fail :noindex: :for: Fail :trait: fmt::Display .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:impl:: impl std::error::Error for Fail :noindex: :for: Fail :trait: std::error::Error .. rust:struct:: pub struct 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). .. rubric:: Fields .. rust:field:: pub code: &'static str Stable identifier ("core.capacity"). .. rust:field:: pub severity: Severity How serious it is. .. rust:field:: pub status: Status The status it fails with, when it is an error. .. rust:field:: pub title: &'static str Upper-case title ("NOT ENOUGH STORAGE"). .. rust:field:: pub message: &'static str Explanation; "{0}" and "{1}" name the arguments. .. rust:field:: pub hint: &'static str How to fix it. .. rust:struct:: pub struct 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. .. rubric:: Implementations .. rust:impl:: impl Reports :noindex: :for: Reports .. rust:method:: pub fn new(max: usize) -> Reports Makes an empty store holding at most ``max`` diagnostics. .. rust:method:: pub fn clear(&mut self, max: usize) Empties the store, keeping its storage, and sets its bound. .. rust:method:: 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. .. rust:method:: pub fn message(&mut self, m: Message, span: SourceSpan, a: Arg, b: Arg) Reports message ``m`` at ``span`` with its arguments, as ``report`` does. .. rust:method:: pub fn items(&self) -> &[Diagnostic] Returns every stored diagnostic, in order. .. rust:method:: pub fn primary(&self) -> Option<&Diagnostic> Returns the first error, if any. .. rust:method:: pub fn first_problem(&self) -> Option<&Diagnostic> Returns the primary error, or the first warning when there is none. .. rust:method:: pub fn error_count(&self) -> usize Returns the number of errors reported (stored or not). .. rust:method:: pub fn warning_count(&self) -> usize Returns the number of warnings reported (stored or not). .. rust:method:: pub fn suppressed_count(&self) -> usize Returns how many diagnostics a full store dropped. .. rust:method:: pub fn is_truncated(&self) -> bool Tells whether the store dropped diagnostics. .. rust:method:: pub fn is_muted(&self) -> bool Tells whether reporting is muted (a trial parse). .. rust:method:: pub fn set_muted(&mut self, muted: bool) -> bool Mutes or unmutes reporting; returns the previous setting, to restore. .. rust:method:: pub fn fatal(&self) -> Status Returns the first error that is not a content error (``Ok`` when none). .. rust:struct:: pub struct 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. .. rubric:: Implementations .. rust:impl:: impl Scratch :noindex: :for: Scratch .. rust:method:: pub fn take(&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. .. rust:method:: pub fn put(&mut self, value: T) Gives ``value`` back for a later conversion to take. .. rust:method:: pub fn len(&self) -> usize Returns the number of types the store keeps values of. .. rust:method:: pub fn is_empty(&self) -> bool Tells whether the store keeps values of no type. .. rust:method:: pub fn release(&mut self) Drops every stored value, releasing its memory. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Scratch :noindex: :for: Scratch :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: pub nodes: Vec Nodes in preorder; ``nodes[0]`` is the Document. .. rust:field:: pub attributes: Vec Attribute rows; each node's are contiguous. .. rust:field:: pub lists: Vec List payload rows. .. rust:field:: pub links: Vec Link payload rows. .. rust:field:: pub cells: Vec Cell payload rows. .. rust:field:: pub text: Vec 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. .. rubric:: Implementations .. rust:impl:: impl Snapshot :noindex: :for: Snapshot .. rust:method:: pub fn clear(&mut self) Empties every table, keeping their storage. .. rust:method:: pub fn node(&self, id: NodeId) -> Option<&Node> Returns node ``id``, or ``None`` when out of range. .. rust:method:: 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). .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: pub name: String Its name (canonical, for included sources). .. rust:field:: pub parent: SourceId The including source; itself for the main source. .. rust:field:: pub included_at: SourceSpan The include directive, when included. .. rust:field:: pub usage: SourceUse How an included source is read. .. rust:struct:: pub struct StackGuard Measures stack use from where it was made. A zero guard is never exhausted. .. rubric:: Implementations .. rust:impl:: impl StackGuard :noindex: :for: StackGuard .. rust:method:: pub fn used(&self) -> usize Returns the stack used between the guard's start and the caller's frame. .. rust:method:: pub fn is_exhausted(&self) -> bool Tells whether the next frame would take the stack past the budget. .. rust:method:: pub fn limit(&self) -> usize Returns the budget in bytes. .. rust:method:: pub fn diagnostic(&self, span: SourceSpan) -> Diagnostic Returns the ``Limit`` diagnostic a guarded recursion reports at ``span``. .. rust:struct:: pub struct SymbolTable A bounded map from names to ``u32`` values. .. rubric:: Implementations .. rust:impl:: impl SymbolTable :noindex: :for: SymbolTable .. rust:method:: 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. .. rust:method:: 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. .. rust:method:: pub fn get(&self, key: &str) -> Option Returns the value stored for ``key``. .. rust:method:: pub fn set(&mut self, key: &str, value: u32) -> bool Replaces the value of an existing key; false when it is absent. .. rust:method:: pub fn count(&self) -> usize Returns the number of names held. .. rust:method:: pub fn clear(&mut self) Empties the table, keeping its storage. .. rust:struct:: pub struct Attribute One attribute row. .. rubric:: Fields .. rust:field:: pub key: AttributeKey The key. .. rust:field:: pub name: Text The key's text when ``key`` is Custom. .. rust:field:: pub value: Text The value. .. rust:struct:: pub struct AttributeRange A node's attributes: rows ``first..first + count`` of the attribute table. .. rubric:: Fields .. rust:field:: pub first: u32 First attribute row. .. rust:field:: pub count: u32 Number of rows. .. rubric:: Implementations .. rust:impl:: impl AttributeRange :noindex: :for: AttributeRange .. rust:method:: pub const fn range(self) -> std::ops::Range :const: Returns the rows as a range of indices. .. rust:struct:: pub struct CapacityNeed What a ``Capacity`` failure needs: the region and the bytes or rows it lacked. .. rubric:: Fields .. rust:field:: pub region: Region The region that ran out. .. rust:field:: pub minimum: u64 The least size that is needed (or the shortfall, when not exact). .. rust:field:: pub exact: bool Whether ``minimum`` is the exact size needed. .. rust:struct:: pub struct CellInfo A Cell node's payload row. .. rubric:: Fields .. rust:field:: pub row_span: u16 Rows spanned (at least 1). .. rust:field:: pub col_span: u16 Columns spanned (at least 1). .. rust:field:: pub align: Align Alignment. .. rubric:: Trait Implementations .. rust:impl:: impl Default for CellInfo :noindex: :for: CellInfo :trait: Default .. rust:method:: fn default() -> CellInfo :noindex: One row by one column, unaligned. .. rust:struct:: pub struct 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. .. rubric:: Fields .. rust:field:: pub text: &'s str The line's text, without its break. .. rust:field:: pub offset: u32 Offset of ``text`` in its source. .. rust:struct:: pub struct LinkInfo A link-like node's payload row. .. rubric:: Fields .. rust:field:: pub destination: Text URL, path, address, or project key. .. rust:field:: pub title: Text Link title. .. rust:field:: pub name: Text Normalized reference name, when named. .. rust:field:: pub resolved: NodeId The referent, meaningful only when ``kind`` is Internal. .. rust:field:: pub kind: LinkKind What the destination means. .. rubric:: Implementations .. rust:impl:: impl LinkInfo :noindex: :for: LinkInfo .. rust:associatedconst:: pub const UNRESOLVED: LinkInfo The row ``link_info`` stands in for a node without one: unresolved, no target. .. rubric:: Trait Implementations .. rust:impl:: impl Default for LinkInfo :noindex: :for: LinkInfo :trait: Default .. rust:method:: fn default() -> LinkInfo :noindex: An External link with no text and ``resolved = INVALID_NODE``. .. rust:struct:: pub struct ListInfo A List node's payload row. .. rubric:: Fields .. rust:field:: pub style: ListStyle Numbering style. .. rust:field:: pub delimiter: u8 '.', ')', or '(' for "(1)"; the bullet character for bullets. .. rust:field:: pub start: i32 First number. .. rubric:: Trait Implementations .. rust:impl:: impl Default for ListInfo :noindex: :for: ListInfo :trait: Default .. rust:method:: fn default() -> ListInfo :noindex: .. rust:struct:: pub struct Node One node of the preorder node table. .. rubric:: Fields .. rust:field:: pub kind: NodeKind What the node is. .. rust:field:: pub flags: NodeFlags Its flags. .. rust:field:: pub subtree_end: u32 The id after its last descendant. .. rust:field:: pub value: i32 A small per-kind scalar (see docs/manual/internals/ast.rst), otherwise zero. .. rust:field:: pub text: Text Its text in the pool. .. rust:field:: pub payload: u32 Its payload row, or ``NONE``. .. rust:field:: pub span: SourceSpan Where it comes from. .. rust:field:: pub attributes: AttributeRange Its attribute rows. .. rust:struct:: pub struct NodeFlags(pub u8) A set of ``NodeFlag``\ s in one byte (saved objects store the byte as it is). .. rubric:: Implementations .. rust:impl:: impl NodeFlags :noindex: :for: NodeFlags .. rust:associatedconst:: pub const EMPTY: NodeFlags = NodeFlags(0) The empty set. .. rust:associatedconst:: pub const TIGHT: NodeFlags = NodeFlags::of(NodeFlag::Tight) ``{Tight}``. .. rust:associatedconst:: pub const ANONYMOUS: NodeFlags = NodeFlags::of(NodeFlag::Anonymous) ``{Anonymous}``. .. rust:associatedconst:: pub const AUTO: NodeFlags = NodeFlags::of(NodeFlag::Auto) ``{Auto}``. .. rust:associatedconst:: pub const SYMBOL: NodeFlags = NodeFlags::of(NodeFlag::Symbol) ``{Symbol}``. .. rust:associatedconst:: pub const LOCAL: NodeFlags = NodeFlags::of(NodeFlag::Local) ``{Local}``. .. rust:associatedconst:: pub const HEADER: NodeFlags = NodeFlags::of(NodeFlag::Header) ``{Header}``. .. rust:associatedconst:: pub const REFERENCED: NodeFlags = NodeFlags::of(NodeFlag::Referenced) ``{Referenced}``. .. rust:associatedconst:: pub const GENERATED: NodeFlags = NodeFlags::of(NodeFlag::Generated) ``{Generated}``. .. rust:method:: pub const fn of(flag: NodeFlag) -> NodeFlags :const: Returns the set holding only ``flag``. .. rust:method:: pub const fn has(self, flag: NodeFlag) -> bool :const: Tells whether ``flag`` is in the set. .. rust:method:: pub const fn contains(self, other: NodeFlags) -> bool :const: Tells whether every flag of ``other`` is in the set. .. rust:method:: pub const fn intersects(self, other: NodeFlags) -> bool :const: Tells whether the sets share a flag. .. rust:method:: pub const fn is_empty(self) -> bool :const: Tells whether the set is empty. .. rust:method:: pub fn insert(&mut self, other: NodeFlags) Adds every flag of ``other``. .. rust:method:: pub fn remove(&mut self, other: NodeFlags) Removes every flag of ``other``. .. rubric:: Trait Implementations .. rust:impl:: impl BitOr for NodeFlags :noindex: :for: NodeFlags :trait: BitOr .. rust:associatedtype:: type Output = NodeFlags :noindex: .. rust:method:: fn bitor(self, o: NodeFlags) -> NodeFlags :noindex: .. rust:impl:: impl BitOrAssign for NodeFlags :noindex: :for: NodeFlags :trait: BitOrAssign .. rust:method:: fn bitor_assign(&mut self, o: NodeFlags) :noindex: .. rust:impl:: impl From for NodeFlags :noindex: :for: NodeFlags :trait: From .. rust:method:: fn from(f: NodeFlag) -> NodeFlags :noindex: .. rust:struct:: pub struct NodeId(pub u32) A node's index in its snapshot's preorder node table. ``ROOT`` is the Document node. .. rubric:: Implementations .. rust:impl:: impl NodeId :noindex: :for: NodeId .. rust:method:: pub const fn index(self) -> usize :const: Returns the id as a ``usize`` index into the node table. .. rust:method:: pub fn from_index(index: usize) -> NodeId Returns the id of node ``index``; indices past ``u32::MAX`` give ``INVALID_NODE``. .. rust:method:: pub const fn plus(self, n: u32) -> NodeId :const: Returns the id ``n`` nodes after this one (saturating). .. rubric:: Trait Implementations .. rust:impl:: impl std::ops::Add for NodeId :noindex: :for: NodeId :trait: std::ops::Add .. rust:associatedtype:: type Output = NodeId :noindex: .. rust:method:: fn add(self, n: u32) -> NodeId :noindex: .. rust:impl:: impl std::ops::Sub for NodeId :noindex: :for: NodeId :trait: std::ops::Sub .. rust:associatedtype:: type Output = NodeId :noindex: .. rust:method:: fn sub(self, n: u32) -> NodeId :noindex: .. rust:struct:: pub struct SourceId(pub u16) An index into a workspace's source table; 0 is the main source. .. rubric:: Implementations .. rust:impl:: impl SourceId :noindex: :for: SourceId .. rust:associatedconst:: pub const MAIN: SourceId = SourceId(0) The main source of a conversion. .. rust:method:: pub const fn index(self) -> usize :const: Returns the id as a ``usize`` index into the source table. .. rust:struct:: pub struct SourceSpan A half-open byte range in one source of the workspace's source table. .. rubric:: Fields .. rust:field:: pub source: SourceId The source the bytes belong to. .. rust:field:: pub start: u32 First byte. .. rust:field:: pub end: u32 One past the last byte. .. rubric:: Implementations .. rust:impl:: impl SourceSpan :noindex: :for: SourceSpan .. rust:method:: pub const fn new(source: SourceId, start: u32, end: u32) -> SourceSpan :const: Makes a span of ``source`` from ``start`` to ``end``. .. rust:method:: pub const fn is_zero(self) -> bool :const: Tells whether the span is the zero span (no source position). .. rust:struct:: pub struct Text A byte range in a snapshot's text pool. .. rubric:: Fields .. rust:field:: pub start: u32 First byte in the pool. .. rust:field:: pub len: u32 Length in bytes. .. rubric:: Implementations .. rust:impl:: impl Text :noindex: :for: Text .. rust:method:: pub const fn range(self) -> std::ops::Range :const: Returns the range ``start..start + len``, which ``Document::text`` slices. .. rust:method:: pub const fn is_empty(self) -> bool :const: Tells whether the text is empty. .. rust:struct:: pub struct Workspace One conversion's storage. Use one workspace per thread; documents borrow it. .. rubric:: Implementations .. rust:impl:: impl Workspace :noindex: :for: Workspace .. rust:method:: pub fn new() -> Workspace Makes an empty workspace with ``default_limits()``. It allocates nothing until used. .. rust:method:: pub fn with_limits(limits: Limits) -> Workspace Makes an empty workspace whose ``convert_text`` uses ``limits``. .. rust:method:: pub fn limits(&self) -> &Limits Returns the limits ``convert_text`` uses. .. rust:method:: pub fn document(&self) -> Option> Returns the current document: the last successful read, pass, or load, until the next conversion starts or the workspace is reset. .. rust:method:: pub fn reports(&self) -> &Reports Returns the reports of the current conversion, valid until the next one. .. rust:method:: pub fn source_map(&self) -> &[MapEntry] Returns the source map the last render recorded (``Request::source_map``). .. rust:method:: pub fn sources(&self) -> &[SourceEntry] Returns the source table of the current conversion. .. rust:method:: pub fn source_str(&self, id: SourceId) -> &str Returns the whole text of source ``id``; "" for an unknown id. .. rust:method:: pub fn source_text(&self, span: SourceSpan) -> &str Returns the source text a span covers, or "" for an invalid span. .. rust:method:: pub fn describe(&self, d: &Diagnostic) -> String Returns a diagnostic's message with its arguments, span arguments quoted from this workspace's sources. .. rust:method:: pub fn scratch(&mut self) -> &mut Scratch Returns the working state readers and renderers keep between conversions. .. rust:method:: pub fn reset(&mut self) Forgets the document, sources, reports, and output, keeping their storage. .. rust:method:: pub fn begin_read<'w>(&'w mut self, request: &'w Request<'w>) -> Result, 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. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Debug for Workspace :noindex: :for: Workspace :trait: fmt::Debug .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rubric:: Enums .. rust:enum:: pub enum Conformance How completely an adapter implements its format. .. rubric:: Variants .. rust:variant:: Planned Not implemented yet. .. rust:variant:: Partial Implemented with known gaps. .. rust:variant:: Conformant Passes its conformance suite. .. rust:enum:: pub enum 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``. .. rubric:: Variants .. rust:variant:: Borrowed(&'a str) The main source, borrowed from the workspace. .. rust:variant:: Shared(Arc) An included or added source. .. rubric:: Trait Implementations .. rust:impl:: impl Deref for SourceText<'_> :noindex: :for: SourceText<'_> :trait: Deref .. rust:associatedtype:: type Target = str :noindex: .. rust:method:: fn deref(&self) -> &str :noindex: .. rust:enum:: pub enum EmitMode What an emitter does with the bytes it is given. .. rubric:: Variants .. rust:variant:: Check Count them only (check_render). .. rust:variant:: Write Store them, up to the limit. .. rust:enum:: pub enum MathMlError Why the filter wrote nothing. .. rubric:: Variants .. rust:variant:: TooLong The text is longer than :rust:const:`MAX_MATHML_BYTES `. .. rust:variant:: TooDeep Elements nest deeper than :rust:const:`MAX_MATHML_DEPTH `. .. rust:variant:: NoRoot The text does not start with a ``math`` element, or has text around it. .. rust:variant:: Malformed A tag is not closed, or an end tag closes another element. .. rubric:: Trait Implementations .. rust:impl:: impl fmt::Display for MathMlError :noindex: :for: MathMlError :trait: fmt::Display .. rust:method:: fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result :noindex: .. rust:impl:: impl std::error::Error for MathMlError :noindex: :for: MathMlError :trait: std::error::Error .. rust:enum:: pub enum MediaKind The media an image path names. .. rubric:: Variants .. rust:variant:: Image A picture. .. rust:variant:: Video A video file. .. rust:variant:: Audio An audio file. .. rust:enum:: pub enum ContentPolicy What to do with content a policy governs. .. rubric:: Variants .. rust:variant:: Refuse An error that names the construct and the policy. .. rust:variant:: Omit A warning; the content is left out. .. rust:variant:: Allow Trusted content is emitted. .. rust:enum:: pub enum 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``. .. rubric:: Variants .. rust:variant:: Attention .. rust:variant:: Caution .. rust:variant:: Danger .. rust:variant:: Error .. rust:variant:: Hint .. rust:variant:: Important .. rust:variant:: Note .. rust:variant:: Tip .. rust:variant:: Warning .. rust:variant:: SeeAlso .. rust:variant:: Todo .. rust:variant:: Contents .. rust:variant:: VersionAdded .. rust:variant:: VersionChanged .. rust:variant:: VersionDeprecated .. rust:variant:: VersionRemoved .. rust:variant:: SectionAuthor .. rust:variant:: ModuleAuthor .. rust:variant:: CodeAuthor .. rust:variant:: LinkHeading .. rust:variant:: LinkDefinition .. rust:variant:: LinkImage .. rust:variant:: LinkTable .. rust:variant:: LinkCode .. rust:variant:: LinkEquation .. rust:variant:: LinkTerm .. rust:variant:: Parameters .. rust:variant:: Variables .. rust:variant:: Raises .. rust:variant:: Returns .. rust:variant:: ReturnType .. rust:variant:: ReturnValues .. rust:variant:: TemplateParameters .. rust:variant:: Throws .. rust:variant:: Arguments .. rust:variant:: Availability .. rust:variant:: UnengravedScore .. rubric:: Implementations .. rust:impl:: impl Label :noindex: :for: Label .. rust:associatedconst:: pub const ALL: [Label; LABEL_COUNT] Every label, in declaration order (``l as usize`` is its index here). .. rust:enum:: pub enum MathStyle How HTML writes math for a script (MathJax, KaTeX) to typeset. .. rubric:: Variants .. rust:variant:: Plain Class "math", the text in ``\( \)`` or ``\[ \]``, as Docutils writes it. .. rust:variant:: Sphinx As Sphinx's mathjax extension writes it. .. rust:enum:: pub enum PassOutcome What a pass did. .. rubric:: Variants .. rust:variant:: Unchanged It left the document as it is (costs nothing). .. rust:variant:: Rebuilt It wrote a new document into the builder. .. rust:variant:: Failed It failed; the previous document stays. .. rust:enum:: pub enum ResourceStatus Why a resource provider did not provide a resource. .. rubric:: Variants .. rust:variant:: Missing It does not exist. .. rust:variant:: Refused The host refuses to provide it. .. rust:variant:: Limit The host's memory budget cannot hold it. .. rust:variant:: NotUtf8 It exists, but its text is not UTF-8. .. rust:enum:: pub enum Arg A diagnostic argument: an integer, a quoted source span, or text. ``{0}`` and ``{1}`` in a message name the arguments. .. rubric:: Variants .. rust:variant:: None No argument. .. rust:variant:: Int(i64) An integer. .. rust:variant:: Span(SourceSpan) The source text of a span, quoted. .. rust:variant:: Text(Cow<'static, str>) Text: static, or owned when it was made at run time. .. rust:enum:: pub enum Severity How serious a diagnostic is. .. rubric:: Variants .. rust:variant:: Note Information only. .. rust:variant:: Warning A problem that does not fail the conversion (unless strict). .. rust:variant:: Error A problem that fails the conversion (unless kept by the policy). .. rust:enum:: pub enum 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. .. rubric:: Variants .. rust:variant:: Parsed Read as markup. .. rust:variant:: Literal Shown as it is. .. rust:enum:: pub enum SymbolClash Why ``SymbolTable::insert`` left the table unchanged. .. rubric:: Variants .. rust:variant:: Duplicate(u32) The key was present, with this value. .. rust:variant:: Full The table holds its capacity. .. rust:enum:: pub enum AdmonitionKind :attributes: #[repr(i32)] An Admonition node's ``value``. .. rubric:: Variants .. rust:variant:: Generic The generic ``admonition`` directive. .. rust:variant:: Attention .. rust:variant:: Caution .. rust:variant:: Danger .. rust:variant:: Error .. rust:variant:: Hint .. rust:variant:: Important .. rust:variant:: Note .. rust:variant:: Tip .. rust:variant:: Warning .. rust:variant:: Seealso .. rust:variant:: Todo .. rubric:: Implementations .. rust:impl:: impl AdmonitionKind :noindex: :for: AdmonitionKind .. rust:associatedconst:: pub const ALL: [AdmonitionKind; 12] Every kind, in value order. .. rust:method:: pub fn from_value(v: i32) -> Option Returns the kind a node's ``value`` holds, or ``None`` when out of range. .. rust:enum:: pub enum Align :attributes: #[repr(u8)] A cell's alignment. .. rubric:: Variants .. rust:variant:: None .. rust:variant:: Left .. rust:variant:: Center .. rust:variant:: Right .. rubric:: Implementations .. rust:impl:: impl Align :noindex: :for: Align .. rust:associatedconst:: pub const ALL: [Align; 4] Every alignment, in declaration order. .. rust:enum:: pub enum AttributeKey :attributes: #[repr(u8)] An attribute's key; ``Custom`` keys carry their name as text. .. rubric:: Variants .. rust:variant:: Custom A key named by the attribute's ``name`` text. .. rust:variant:: Class .. rust:variant:: Id .. rust:variant:: Name .. rust:variant:: Language .. rust:variant:: Alt .. rust:variant:: Width .. rust:variant:: Height .. rust:variant:: Scale .. rust:variant:: Align .. rust:variant:: Format .. rust:variant:: Title .. rust:variant:: Target .. rust:variant:: Start .. rust:variant:: Widths .. rust:variant:: Source .. rubric:: Implementations .. rust:impl:: impl AttributeKey :noindex: :for: AttributeKey .. rust:associatedconst:: pub const ALL: [AttributeKey; 16] Every key, in declaration order. .. rust:method:: pub const fn name(self) -> &'static str :const: Returns the static name dumps write ("class"); "custom" for Custom. .. rust:enum:: pub enum Content What children a kind may have; see ``child_allowed``. .. rubric:: Variants .. rust:variant:: Nothing No children. .. rust:variant:: Blocks Block children. .. rust:variant:: Inlines Inline children. .. rust:variant:: Structure Children of specific kinds only. .. rust:enum:: pub enum DocumentReading :attributes: #[repr(i32)] A Document node's ``value``: who read it, which decides the ids anchors give. .. rubric:: Variants .. rust:variant:: Docutils = 0 Read as Docutils reads it. .. rust:variant:: Sphinx = 1 Read by the Sphinx layer. .. rust:enum:: pub enum LinkKind :attributes: #[repr(u8)] What a link row's destination means. .. rubric:: Variants .. rust:variant:: External Destination is a URL or path. .. rust:variant:: Email Destination is an address; HTML adds ``mailto:``. .. rust:variant:: Internal ``resolved`` is a node of this document. .. rust:variant:: Unresolved The name awaits resolution. .. rust:variant:: Project Destination is a project anchor key in another document. .. rubric:: Implementations .. rust:impl:: impl LinkKind :noindex: :for: LinkKind .. rust:associatedconst:: pub const ALL: [LinkKind; 5] Every kind, in declaration order. .. rust:method:: pub const fn name(self) -> &'static str :const: Returns the static name dumps write. .. rust:enum:: pub enum ListStyle :attributes: #[repr(u8)] A list's numbering style. .. rubric:: Variants .. rust:variant:: Bullet .. rust:variant:: Arabic .. rust:variant:: LowerAlpha .. rust:variant:: UpperAlpha .. rust:variant:: LowerRoman .. rust:variant:: UpperRoman .. rubric:: Implementations .. rust:impl:: impl ListStyle :noindex: :for: ListStyle .. rust:associatedconst:: pub const ALL: [ListStyle; 6] Every style, in declaration order. .. rust:method:: pub const fn name(self) -> &'static str :const: Returns the static name dumps write ("loweralpha"). .. rust:enum:: pub enum NodeFlag :attributes: #[repr(u8)] One node flag; ``NodeFlags`` holds a set of them. .. rubric:: Variants .. rust:variant:: Tight List: items render without paragraph spacing. .. rust:variant:: Anonymous Reference or Target: anonymous hyperlink. .. rust:variant:: Auto Footnote or reference: auto-numbered. .. rust:variant:: Symbol Footnote or reference: auto-symbol. .. rust:variant:: Local Contents: only the enclosing section. .. rust:variant:: Header Row or Cell: belongs to a header. .. rust:variant:: Referenced Target or Footnote: something refers to it. .. rust:variant:: Generated Created by resolution rather than markup. .. rubric:: Implementations .. rust:impl:: impl NodeFlag :noindex: :for: NodeFlag .. rust:associatedconst:: pub const ALL: [NodeFlag; 8] Every flag, in bit order. .. rust:method:: pub const fn name(self) -> &'static str :const: Returns the static name dumps write ("tight"). .. rust:enum:: pub enum NodeKind :attributes: #[repr(u8)] Every kind of node. docs/manual/internals/ast.rst documents each kind's children and fields. .. rubric:: Variants .. rust:variant:: Document The root. .. rust:variant:: Title .. rust:variant:: Subtitle .. rust:variant:: Section .. rust:variant:: Heading .. rust:variant:: Paragraph .. rust:variant:: BlockQuote .. rust:variant:: Attribution .. rust:variant:: List .. rust:variant:: ListItem .. rust:variant:: DefinitionList .. rust:variant:: DefinitionItem .. rust:variant:: Term .. rust:variant:: Classifier .. rust:variant:: Definition .. rust:variant:: FieldList .. rust:variant:: Field .. rust:variant:: FieldName .. rust:variant:: FieldBody .. rust:variant:: OptionList .. rust:variant:: OptionItem .. rust:variant:: OptionGroup .. rust:variant:: Option .. rust:variant:: OptionArgument .. rust:variant:: OptionDescription .. rust:variant:: LineBlock .. rust:variant:: Line .. rust:variant:: CodeBlock .. rust:variant:: Preformatted .. rust:variant:: DoctestBlock .. rust:variant:: MathBlock .. rust:variant:: RawBlock .. rust:variant:: ThematicBreak .. rust:variant:: Table .. rust:variant:: TableHead .. rust:variant:: TableBody .. rust:variant:: Row .. rust:variant:: Cell .. rust:variant:: Figure .. rust:variant:: Caption .. rust:variant:: Legend .. rust:variant:: Admonition .. rust:variant:: Topic .. rust:variant:: Sidebar .. rust:variant:: Rubric .. rust:variant:: Container .. rust:variant:: Compound .. rust:variant:: Footnote .. rust:variant:: Citation .. rust:variant:: Target .. rust:variant:: Comment .. rust:variant:: SubstitutionDefinition .. rust:variant:: Contents .. rust:variant:: Directive .. rust:variant:: Toctree .. rust:variant:: ToctreeEntry .. rust:variant:: Only .. rust:variant:: Glossary .. rust:variant:: VersionModified .. rust:variant:: Desc .. rust:variant:: DescSignature .. rust:variant:: DescContent .. rust:variant:: Hlist .. rust:variant:: ProductionList .. rust:variant:: Production .. rust:variant:: Index .. rust:variant:: Text .. rust:variant:: Emphasis .. rust:variant:: Strong .. rust:variant:: Code .. rust:variant:: Link .. rust:variant:: Reference .. rust:variant:: Image .. rust:variant:: FootnoteReference .. rust:variant:: CitationReference .. rust:variant:: SubstitutionReference .. rust:variant:: InlineTarget .. rust:variant:: Math .. rust:variant:: RawInline .. rust:variant:: SoftBreak .. rust:variant:: HardBreak .. rust:variant:: Subscript .. rust:variant:: Superscript .. rust:variant:: TitleReference .. rust:variant:: Abbreviation .. rust:variant:: Role .. rust:variant:: Xref .. rust:variant:: DescName .. rust:variant:: DescAddname .. rust:variant:: DescAnnotation .. rust:variant:: DescParameterlist .. rust:variant:: DescParameter .. rust:variant:: DescOptional .. rust:variant:: DescReturns .. rubric:: Implementations .. rust:impl:: impl NodeKind :noindex: :for: NodeKind .. rust:associatedconst:: pub const ALL: [NodeKind; 94] Every kind, in declaration order (``ALL[k as usize] == k``). .. rust:impl:: impl NodeKind :noindex: :for: NodeKind .. rust:method:: pub fn from_u8(v: u8) -> Option Returns the kind numbered ``v`` (its declaration order), or ``None``. .. rust:enum:: pub enum Region A storage region named by a capacity failure. .. rubric:: Variants .. rust:variant:: None No region. .. rust:variant:: Nodes The node table. .. rust:variant:: Text The text pool. .. rust:variant:: Attributes The attribute table. .. rust:variant:: Lists The list payload table. .. rust:variant:: Links The link payload table. .. rust:variant:: Cells The cell payload table. .. rust:variant:: Sources The source table. .. rust:variant:: Scratch Working memory of an adapter. .. rust:variant:: Reports The report store. .. rust:variant:: Output The rendered output. .. rust:variant:: SourceMap The source map. .. rubric:: Implementations .. rust:impl:: impl Region :noindex: :for: Region .. rust:method:: pub const fn name(self) -> &'static str :const: Returns the static name diagnostics write ("nodes"). .. rust:enum:: pub enum Status The outcome class of a stage. ``Ok`` is kept so builders can report their state. .. rubric:: Variants .. rust:variant:: Ok Success. .. rust:variant:: InvalidInput The input (or a document, request or registry) is invalid. .. rust:variant:: Unsupported The input asks for something no adapter supports. .. rust:variant:: Policy The policy refused something. .. rust:variant:: Capacity Memory ran out; ``CapacityNeed`` says where. .. rust:variant:: Limit A configured limit was reached. .. rust:variant:: Cancelled The caller cancelled the conversion. .. rust:variant:: Internal A bug in an adapter or the core. .. rubric:: Traits .. rust:trait:: pub trait 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. .. rust:method:: fn highlight(&self, language: &str, code: &str, out: &mut Emitter<'_>) -> bool Writes ``code`` in ``language`` as highlighted HTML into ``out``. .. rust:trait:: pub trait 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. .. rust:method:: fn write_math(&self, latex: &str, display: bool, out: &mut Emitter<'_>) -> bool Writes the formula ``latex`` (inline, or displayed when ``display``) into ``out``. .. rust:trait:: pub trait 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. .. rust:method:: fn provide(&self, from: &str, name: &str) -> Result Returns the resource ``name`` that source ``from`` asks for. .. rust:trait:: pub trait 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. .. rust:method:: fn put_str(&mut self, s: &str) Appends ``s``. .. rust:method:: fn put_char(&mut self, c: char) :provided: Appends one character. .. rubric:: Implementors .. rust:impl:: impl TextSink for Builder<'_> :noindex: :module: guidedoc::builder :for: Builder<'_> :trait: TextSink .. rust:impl:: impl TextSink for Emitter<'_> :noindex: :module: guidedoc::emit :for: Emitter<'_> :trait: TextSink .. rust:impl:: impl TextSink for String :noindex: :for: String :trait: TextSink .. rust:impl:: impl TextSink for Vec :noindex: :for: Vec :trait: TextSink .. rubric:: Functions .. rust:function:: pub fn validate_registry(r: &Registry) -> Result<(), Fail> Validates a registry: fails when an adapter lacks metadata or is registered twice. .. rust:function:: pub fn 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). .. rust:function:: pub fn 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. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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". .. rust:function:: pub fn 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. .. rust:function:: pub fn check_render(ws: &mut Workspace, renderer: &Renderer, request: &Request<'_>) -> Result Runs the renderer without storing output and returns the exact output size; every support problem is reported as a render would report it. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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, ®istry, "commonmark", "html", text)``. .. rust:function:: pub fn read_document<'w>(ws: &'w mut Workspace, reader: &Reader, request: &Request<'_>) -> Result, 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. .. rust:function:: pub fn 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. .. rust:function:: pub fn transform_document<'w>(ws: &'w mut Workspace, passes: &[Pass<'_>], limits: &Limits) -> Result, 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. .. rust:function:: pub fn dump_to_string(doc: Document<'_>) -> String Returns the outline of ``doc`` as a new string (for tests and debugging). .. rust:function:: pub fn 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. .. rust:function:: pub fn admonition_name(k: AdmonitionKind) -> &'static str Returns the static class name of an admonition kind ("note", "tip"). .. rust:function:: pub fn child_allowed(parent: NodeKind, child: NodeKind) -> bool States the legal parent-child pairs. Builders and validation share it. .. rust:function:: pub fn content_model(k: NodeKind) -> Content Tells what children nodes of kind ``k`` may have; see ``child_allowed``. Exhaustive, as ``payload_of`` is. .. rust:function:: pub fn kind_name(k: NodeKind) -> &'static str Returns the static name of a node kind, as dumps and diagnostics write it. .. rust:function:: pub fn check_math(latex: &str, options: &MathCheck<'_>) -> Option Checks one formula alone. See :rust:fn:`MathChecker::check `. .. rust:function:: pub fn is_math_command(name: &str) -> bool Tells whether ``name`` (without the backslash) is a LaTeX math command we know. .. rust:function:: pub fn is_math_environment(name: &str) -> bool Tells whether ``name`` is a LaTeX math environment we know. .. rust:function:: pub fn suggest_math_command(name: &str) -> Option<&'static str> The known command closest to the misspelled ``name``, if one is close. .. rust:function:: pub fn suggest_math_environment(name: &str) -> Option<&'static str> The known environment closest to the misspelled ``name``, if one is close. .. rust:function:: pub fn filter_mathml(input: &str, options: &MathMlOptions<'_>, out: &mut String) -> Result 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. .. rust:function:: pub fn media_kind(path: &str) -> MediaKind Reads a path's extension, ignoring case, a query, and a fragment. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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). .. rust:function:: pub fn 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. .. rust:function:: pub fn load_object<'w>(ws: &'w mut Workspace, bytes: &[u8], limits: &Limits) -> Result, 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. .. rust:function:: pub fn write_object(doc: Document<'_>, out: &mut Vec) Appends ``doc``, with its sources, to ``out`` as object bytes. .. rust:function:: pub fn admonition_label<'a>(options: &RenderOptions<'a>, k: AdmonitionKind) -> &'a str Returns the title of an admonition kind; "" for a generic admonition. .. rust:function:: pub fn 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. .. rust:function:: pub fn default_policy() -> Policy Returns the safe policy: raw content, unsafe URLs, and untranslatable math refused; includes may be requested. .. rust:function:: pub fn default_read_options() -> ReadOptions<'static> Returns the read options: title promotion on, tab width 8, no reader settings, the math check on. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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. .. rust:function:: pub fn label<'a>(options: &RenderOptions<'a>, l: Label) -> &'a str Returns a label in the render's language, or in English when it has none. .. rust:function:: pub fn read_extension(settings: &T) -> ReadExtension<'_> Wraps borrowed reader settings with their type; they must outlive the read. .. rust:function:: pub fn split_label(s: &str) -> (&str, &str) Splits a label at its "%s": the text before and after the value. .. rust:function:: pub fn trusted_policy() -> Policy Returns the policy for conformance tests and content the caller wrote: everything allowed. .. rust:function:: pub fn unengraved_score(doc: Document<'_>, id: crate::NodeId, options: &RenderOptions<'_>) -> Option 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. .. rust:function:: pub fn 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 ``/``. .. rust:function:: pub fn arg_int(v: i64) -> Arg Makes an integer argument. .. rust:function:: pub fn arg_span(s: SourceSpan) -> Arg Makes an argument that quotes the source text of ``s``. .. rust:function:: pub fn arg_static(s: &'static str) -> Arg Makes an argument of static text; it copies nothing. .. rust:function:: pub fn arg_text(s: &str) -> Arg Makes an argument of text that does not live long enough to borrow; it copies ``s``. .. rust:function:: pub fn 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. .. rust:function:: pub fn diagnostic(m: Message, span: SourceSpan, a: Arg, b: Arg) -> Diagnostic Builds a diagnostic from message ``m`` at ``span`` with up to two arguments. .. rust:function:: pub fn 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. .. rust:function:: pub fn recycle(mut buffer: Vec) -> Vec 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>``, borrowing one conversion's source) in its scratch as ``Vec>``, 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. .. rust:function:: pub fn stack_diagnostic(g: &StackGuard, span: SourceSpan) -> Diagnostic Returns the diagnostic a guard's recursion reports. .. rust:function:: pub fn stack_exhausted(g: &StackGuard) -> bool Tells whether the guard's budget is spent. .. rust:function:: pub fn stack_guard(limits: &Limits) -> StackGuard Starts measuring at the caller's frame, with the limits' stack budget. .. rust:function:: pub fn 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``. .. rust:function:: pub fn decode_last_rune(s: &str, end: usize) -> (char, usize) Decodes the character ending at byte ``end`` of ``s``, as ``decode_rune`` does. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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. .. rust:function:: pub fn is_ascii_alnum(c: u8) -> bool Tells whether ``c`` is an ASCII letter or digit. .. rust:function:: pub fn is_ascii_digit(c: u8) -> bool Tells whether ``c`` is an ASCII digit. .. rust:function:: pub fn is_ascii_punct(c: u8) -> bool Tells whether ``c`` is ASCII punctuation, as CommonMark defines it. .. rust:function:: pub fn is_ascii_space(c: u8) -> bool Tells whether ``c`` is ASCII white space: space, tab, LF, CR, FF, or VT. .. rust:function:: pub fn is_decimal_digit(r: char) -> bool Tells whether ``r`` is a decimal digit (general category Nd). .. rust:function:: pub fn is_letter(r: char) -> bool Tells whether ``r`` is a letter (general category L). .. rust:function:: pub fn is_unicode_punctuation(r: char) -> bool Tells whether ``r`` is punctuation as CommonMark 0.31 defines it: general categories P and S. .. rust:function:: pub fn is_unicode_whitespace(r: char) -> bool Tells whether ``r`` is white space as CommonMark defines it: Zs characters, tab, LF, FF, and CR. .. rust:function:: pub fn line_bounds(text: &str, offset: usize) -> (usize, usize) Returns the byte range of the line holding ``offset``, without its break. .. rust:function:: pub fn line_column(text: &str, offset: usize) -> (usize, usize) Converts a byte offset into a 1-based line and byte column. .. rust:function:: pub fn 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. .. rust:function:: pub fn 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'). .. rust:function:: pub fn offset_in(outer: &str, inner: &str) -> Option 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. .. rust:function:: pub fn 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. .. rubric:: Type Aliases .. rust:type:: pub type ReadFn = fn(&mut ReadContext<'_>) -> Result<(), Fail> Reads ``ctx.source`` into ``ctx.b``. .. rust:type:: pub type 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``. .. rust:type:: pub type RenderFn = fn(&mut RenderContext<'_>) -> Result<(), Fail> Writes ``ctx.doc`` with ``ctx.out``. .. rust:type:: pub type PassFn<'a> = dyn Fn(Document<'_>, &mut Builder<'_>) -> PassOutcome + 'a The function of a pass: it reads an immutable document and may rebuild it. .. rubric:: Constants .. rust:const:: pub const BUILDER_OPEN: u32 = u32::MAX - 1 The subtree end of a node that is still open. .. rust:const:: pub const MATH_ALIGNMENT: Message ``&`` or ``\\`` where nothing aligns. .. rust:const:: pub const MATH_ARGUMENT: Message A command followed by fewer arguments than it takes. .. rust:const:: pub const MATH_BRACE: Message A ``{`` without its ``}``, or a ``}`` without its ``{``. .. rust:const:: pub const MATH_COMMAND_UNKNOWN: Message A command no LaTeX math vocabulary we know has. .. rust:const:: pub const MATH_DELIMITER: Message A ``\left`` without its ``\right``, or a ``\right`` without its ``\left``. .. rust:const:: pub const MATH_ENVIRONMENT_MISMATCH: Message An ``\end`` that names another environment than the open one. .. rust:const:: pub const MATH_ENVIRONMENT_UNCLOSED: Message A ``\begin`` without its ``\end``, or an ``\end`` without its ``\begin``. .. rust:const:: pub const MATH_ENVIRONMENT_UNKNOWN: Message An environment no LaTeX math vocabulary we know has. .. rust:const:: pub const MAX_FORMULA_BYTES: usize = 64 << 10 The longest formula checked, in bytes. A longer one is left alone. .. rust:const:: pub const MATHML_ATTRIBUTES: [&str; 26] The attributes the filter keeps, on any kept element. .. rust:const:: pub const MATHML_ELEMENTS: [&str; 28] The elements the filter keeps: MathML Core's presentation elements. .. rust:const:: pub const MAX_MATHML_BYTES: usize = 256 << 10 The longest MathML text the filter reads, in bytes. .. rust:const:: pub const MAX_MATHML_DEPTH: usize = 128 The deepest element nesting the filter follows. .. rust:const:: pub const ENGLISH_LABELS: [&str; LABEL_COUNT] The labels in English (Sphinx's msgids), indexed by ``Label as usize``. .. rust:const:: pub const LABEL_COUNT: usize = 37 The number of labels. .. rust:const:: pub const 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 :rust:fn:`is_mathml `). .. rust:const:: pub const 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. .. rust:const:: pub const CORE_CAPACITY: Message A region ran out of memory; ``{0}`` names it and ``{1}`` the shortfall. .. rust:const:: pub const CORE_DEPTH: Message Nesting past ``Limits::max_depth``. .. rust:const:: pub const CORE_NODES: Message More than ``Limits::max_nodes`` nodes. .. rust:const:: pub const CORE_STACK: Message Recursion past ``Limits::stack_bytes``. .. rust:const:: pub const CORE_UNHANDLED_KIND: Message A renderer routed a node to a handler that does not write it. .. rust:const:: pub const CORE_UTF8: Message A bytes source is not UTF-8. .. rust:const:: pub const CORE_WORK: Message More than ``Limits::max_work`` steps. .. rust:const:: pub const INCLUDE_MISSING: Message The provider has no such resource. Readers report it too (literalinclude). .. rust:const:: pub const 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). .. rust:const:: pub const 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. .. rust:const:: pub const INVALID_NODE: NodeId = NodeId(u32::MAX) "No node": the table value for a node that is absent. .. rust:const:: pub const NONE: u32 = u32::MAX "No row": a node's payload when it has none. .. rust:const:: pub const ROOT: NodeId = NodeId(0) The root Document node of every snapshot. .. rust:const:: pub const VERSION: &str = env!("CARGO_PKG_VERSION") The engine's version: the project version every crate inherits. .. rust:const:: pub const SCHEMA_VERSION: u32 = 1 Counts the incompatible changes to documents saved as objects (``write_object``).