pub struct TextModel { /* private fields */ }Expand description
A Quarb adapter over a text-level document.
Implementations§
Source§impl TextModel
impl TextModel
Sourcepub fn build(blocks: Vec<Block>) -> Self
pub fn build(blocks: Vec<Block>) -> Self
Assemble the document tree from a adapter’s event stream.
Iterative throughout (the stream is flat; prose flattening
runs over indices), so pathological nesting cannot overflow
the call stack. Lenient on malformed streams: a stray
Close is ignored, unclosed containers close at the end.
Sourcepub fn set_bib_aliases(&mut self, map: HashMap<String, String>)
pub fn set_bib_aliases(&mut self, map: HashMap<String, String>)
Register the bib-field alias census (alias → canonical campus), lowercased keys — the friction remover: a field authored or queried under any covered name answers.
Sourcepub fn set_document_url(&mut self, url: &str)
pub fn set_document_url(&mut self, url: &str)
Declare the document’s own URL — the base a relative ref
target joins against when --> reaches across documents.
Sourcepub fn parse_plain(text: &str) -> Self
pub fn parse_plain(text: &str) -> Self
Read plain text: blank-line-separated paragraphs, each collapsed to one line — the atramento paragraph rule. No headings, no markup.
Trait Implementations§
Source§impl AstAdapter for TextModel
impl AstAdapter for TextModel
Source§fn traits(&self, node: NodeId) -> Vec<String>
fn traits(&self, node: NodeId) -> Vec<String>
The <block> family on every block node, plus <table> on
a list that denormalizes a table. Kinds are node names, not
traits.
Source§fn property(&self, node: NodeId, name: &str) -> Option<Value>
fn property(&self, node: NodeId, name: &str) -> Option<Value>
::lemma (title), ::hypograph (footer or attribution),
::taxis (ordinal), ::text (the flattened prose, same as
the bare projection).
The Greek anatomy — ::lemma, ::grammata, ::hypograph,
::taxis — plus the friendly aliases (::title, ::body,
::attribution, ::ord), answered here because this
adapter’s property surface IS the vocabulary; on data
adapters those spellings stay ordinary field names. The
Greek is canon in docs and reflection preserves whichever
spelling was written.
Source§fn default_value(&self, node: NodeId) -> Option<Value>
fn default_value(&self, node: NodeId) -> Option<Value>
The default projection is the flattened prose of the subtree — lemma first, hypograph last.
Source§fn links(&self, node: NodeId) -> Vec<(String, NodeId)>
fn links(&self, node: NodeId) -> Vec<(String, NodeId)>
The edge label is the family name both ends share —
->footnote / ->endnote — the node’s own kind, since
resolution re-kinds an open-family callout to its body.
Source§fn resolve(
&self,
node: NodeId,
property: &str,
hint: Option<&str>,
) -> Option<NodeId>
fn resolve( &self, node: NodeId, property: &str, hint: Option<&str>, ) -> Option<NodeId>
//ref-->: land on the bearer — the block if a block
bears the name, the point anchor if a point does. The
text-level hints choose the reading: -->block normalizes
a point landing to its enclosing block, -->point selects
point targets only; bare is the honest exact landing.
Source§fn ref_property(&self, node: NodeId) -> Option<String>
fn ref_property(&self, node: NodeId) -> Option<String>
The bare arrow’s property: a ref resolves its target.
Source§fn external_ref(
&self,
node: NodeId,
property: &str,
hint: Option<&str>,
) -> Option<String>
fn external_ref( &self, node: NodeId, property: &str, hint: Option<&str>, ) -> Option<String>
A ref the producer declared external: the absolute URL, relative targets joined against the document’s own URL — the same acquisition rung the html DOM reading speaks.
Source§fn resolve_fragment(&self, _node: NodeId, fragment: &str) -> Option<NodeId>
fn resolve_fragment(&self, _node: NodeId, fragment: &str) -> Option<NodeId>
A sibling document’s #fragment lands here: the bearer of
that name — a labeled block, or a point anchor.
Source§fn aliased_metadata(&self, _node: NodeId) -> &'static [&'static str]
fn aliased_metadata(&self, _node: NodeId) -> &'static [&'static str]
Ruling #29: the text level’s surface is the vocabulary
itself — no document can introduce a property name — so
its two annotations answer at :: as well.
Source§fn metadata(&self, node: NodeId, key: &str) -> Option<Value>
fn metadata(&self, node: NodeId, key: &str) -> Option<Value>
::::level on sections (the source heading level) and
::::lang on verbatim blocks (the declared language).
Source§fn children(&self, node: NodeId) -> Vec<NodeId>
fn children(&self, node: NodeId) -> Vec<NodeId>
node, in document order. Read moreSource§fn name(&self, node: NodeId) -> Option<String>
fn name(&self, node: NodeId) -> Option<String>
node — the label of its incoming tree edge. Read moreSource§fn backlinks(&self, node: NodeId) -> Vec<(String, NodeId)>
fn backlinks(&self, node: NodeId) -> Vec<(String, NodeId)>
node, as (label, source) pairs, for
<- navigation. May be expensive (an adapter that does not
precompute edges must search for referrers).Source§fn children_named(&self, node: NodeId, name: &str) -> Vec<NodeId>
fn children_named(&self, node: NodeId, name: &str) -> Vec<NodeId>
node whose edge name is exactly name —
the engine’s fast path for name-matcher child hops. The
default filters children; an adapter
whose containers cannot be enumerated (permission-scoped or
unbounded remote trees) overrides this with a direct,
name-addressed lookup. Must be observationally identical to
the default wherever enumeration works. The adapter owns the
name test: it may deliberately alias — resolve a name to a
node whose edge name differs (git revision syntax landing on
a hash-named commit) — and the engine will not re-filter.
Container-scoped resolution like that stays child-axis only;
per-node spelling aliases belong in
answers_to, which this default
consults.Source§fn answers_to(&self, node: NodeId, name: &str) -> bool
fn answers_to(&self, node: NodeId, name: &str) -> bool
node answers to name as a literal spelling
(ruling #30). The default is canonical equality. An adapter
may declare per-node aliases — a social feed spelling a
handle @alice while the stripped alice is the hop name —
and the engine consults this wherever a literal name is
matched, on every axis, so one override keeps /@alice and
//@alice in agreement. :::name stays canonical (locators
and reflection print it; an alias is a way in, never a way
out), and name patterns (~(...), *) test the canonical
name only.Source§fn ref_label(&self, _node: NodeId, _property: &str) -> Option<String>
fn ref_label(&self, _node: NodeId, _property: &str) -> Option<String>
node via
property carries — html’s rel attribute. None falls
back to the property name as the edge label.Source§fn link_property(
&self,
_source: NodeId,
_label: &str,
_target: NodeId,
_name: &str,
) -> Option<Value>
fn link_property( &self, _source: NodeId, _label: &str, _target: NodeId, _name: &str, ) -> Option<Value>
source --label--> target — the
$-::prop read. Adapters whose edges carry data (a property
graph’s relationship properties) override this; None if the
edge is bare or unknown. Where parallel edges share source,
label, and target, the adapter answers for one of them,
consistently.Source§fn quantifier_bound(&self) -> usize
fn quantifier_bound(&self) -> usize
+, *, {m,}) expand, and the ceiling of any
explicit {m,n} (the effective upper bound is min(n, N_max)).
An adapter whose natural structures run deep may raise it; the
CLI overrides it per run (qua --quantifier-bound).Source§fn allow_shell(&self) -> bool
fn allow_shell(&self) -> bool
sh(...) pipeline stage may run external
commands. False by default — query text stays inert data —
and enabled per run by the CLI (qua --allow-shell) through
the AllowShell wrapper.Source§fn invocation_instant(&self) -> Option<(i64, u32)>
fn invocation_instant(&self) -> Option<(i64, u32)>
now() denotes (spec: The Temporal
Fragment, Determinism): one UTC timeline point bound by the
runner BEFORE evaluation begins — evaluation itself never
reads a clock. None by default (a library run is fully
deterministic; now() reads as null); the CLI binds it at
startup — pinnable with qua --now — through the
WithNow wrapper.Source§fn provenance(&self, _node: NodeId) -> Provenance
fn provenance(&self, _node: NodeId) -> Provenance
node — the :::source /
:::instant / :::dpid / :::provenance core-metadata
keys. Empty by default: an adapter answers only the
components its substrate genuinely records (never the
invocation clock); wrapper adapters fill missing components
from what they know — the mount its target, a graft its
outer leaf, a model its derivation — and forward the rest
inward, so resolution is nearest-ancestor per component.Source§fn unit_scale(&self, expr: &str) -> Option<(f64, String)>
fn unit_scale(&self, expr: &str) -> Option<(f64, String)>
[::range < '50kellicam'] resolves through the
document’s .!units imports.