pub struct By {
pub kind: String,
pub data: Value,
}Expand description
Producer identity for a SourceInfo::Generated node.
kind is a short, kebab-case identifier describing which transform
produced the node (“filter”, “shortcode”, “sectionize”, …). Third
parties should namespace as ext/<extension>/<kind>.
data is per-kind configuration that is not a source-info pointer.
Source-side anchors live in the parent Generated.from list, not here.
Null for kinds that don’t carry per-instance data.
Fields§
§kind: StringShort kind tag, kebab-case. Examples: “filter”, “shortcode”, “sectionize”, “user-edit”, “title-block”. Third-party kinds should namespace: “ext/my-extension/foo”.
data: ValuePer-kind configuration that is NOT a source-info pointer.
Anchors live in Generated.from, not here.
Null for kinds that don’t carry per-instance data.
Implementations§
Source§impl By
impl By
Sourcepub fn filter(filter_path: impl Into<String>, line: usize) -> Self
pub fn filter(filter_path: impl Into<String>, line: usize) -> Self
Producer kind for a node constructed by a Lua filter
(e.g. pandoc.Str("decoration") inside a filter callback).
filter_path is the path the Lua engine reported via
debug.getinfo(...).source (with the leading “@” stripped);
line is the line number inside that file where the constructor
ran. Until Lua-file-registration lands (bd-36fr9), (filter_path, line) lives in by.data; afterwards it migrates to a Dispatch
anchor and by.data shrinks to {}.
Sourcepub fn sectionize() -> Self
pub fn sectionize() -> Self
Producer kind for the SectionizeTransform’s synthesized section
Divs. Children remain editable; the wrapper itself is structural.
Sourcepub fn user_edit() -> Self
pub fn user_edit() -> Self
Producer kind for React-constructed (user-typed) content reaching the AST through the q2-preview client.
Sourcepub fn shortcode(name: impl Into<String>) -> Self
pub fn shortcode(name: impl Into<String>) -> Self
Producer kind for shortcode resolutions.
Invariant. Every Generated { by: shortcode(...), .. } must
carry at least one Invocation anchor in from pointing at the
source token’s byte range. Use only inside a Generated whose
anchor list is populated; constructing the bare shape with empty
from is rejected by Plan 6’s audit-completion test and trips
Plan 7’s writer debug_assert!.
Sourcepub fn include() -> Self
pub fn include() -> Self
Producer kind for IncludeStage’s expansion wrapper. Note that
most include-related synthesized content keeps its Original
source_info (inherited from the include-line Paragraph) — this
kind is only used where a Generated is explicitly required.
Sourcepub fn title_block() -> Self
pub fn title_block() -> Self
Producer kind for the title-block stage’s synthesized title h1.
Sourcepub fn revealjs() -> Self
pub fn revealjs() -> Self
Producer kind for RevealSlidesTransform’s synthesized slide
structure — title-slide Div, section wrappers, speaker-notes Div,
and any other chrome built from the slide-level heading tree.
Non-atomic: the slide container is structural chrome; the content
inside (headings, paragraphs) retains its own source_info.
Sourcepub fn tree_sitter_postprocess() -> Self
pub fn tree_sitter_postprocess() -> Self
Producer kind for parser-side synthetic Spaces inserted by the tree-sitter post-processing pass.
Sourcepub fn unknown() -> Self
pub fn unknown() -> Self
“We don’t know” placeholder used by json::read_completing_source_info
when a node arrives without an s: field from outside the q2
source-tracking world (qmd-syntax-helper Pandoc subprocess, CLI
--from json, external filter binaries, Lua AST handoff).
Non-atomic by design — nodes carrying By::unknown() remain
editable in the preview; user edits re-stamp them as user_edit
on save. See Plan 7f Phase 4’s per-caller table for placement
guidance.
Sourcepub fn test_scaffold() -> Self
pub fn test_scaffold() -> Self
Producer kind for test scaffolding. Non-atomic; appears only in
test code where source_info is required by a constructor but
has no real provenance to record. Paired with
SourceInfo::for_test.
Sourcepub fn citeproc() -> Self
pub fn citeproc() -> Self
Producer kind for citeproc-rendered content (citation Str
replacements, bibliography Divs, #refs wrappers). The bytes
come from CSL processing of bibliographic metadata, not from
user-written source.
Atomic — citeproc output is generated content the user can’t edit through the preview; changes go through the CSL pipeline, not through inline editing.
Sourcepub fn jupyter_output() -> Self
pub fn jupyter_output() -> Self
Producer kind for content synthesized from execution-engine output (Jupyter cell stdout / stderr, rich-display MIME bundles, kernel error tracebacks). The bytes come from kernel execution, not from user-written source.
Atomic — execution outputs are regenerated on every re-run; editing them through the preview would be a UX bug.
Sourcepub fn callout() -> Self
pub fn callout() -> Self
Producer kind for callout-decoration synthesis:
default-title injection (Note, Warning, etc. when the user
omits a title and appearance="default") and the
screen-reader-only type announcement span.
Non-atomic — the wrapper Div is structural, and its children (the user’s actual callout body) remain editable through the preview. The synthesized title text itself has no preimage but regenerates from the callout type when the user changes it, so atomicity at the wrapper level would be incorrect.
Sourcepub fn config_default() -> Self
pub fn config_default() -> Self
Empty-Map sentinel ConfigValue used during metadata merging
when no value is present. Non-atomic. The bytes don’t exist —
the node is structural. See By::is_programmatic_sentinel.
Sourcepub fn programmatic_config() -> Self
pub fn programmatic_config() -> Self
Programmatic construction of ConfigValue (e.g.
ConfigValue::from_path, intermediate maps created during
insert_path). No source bytes exist for these nodes.
See By::is_programmatic_sentinel.
Sourcepub fn is_programmatic_sentinel(&self) -> bool
pub fn is_programmatic_sentinel(&self) -> bool
True for kinds whose source bytes don’t exist — config-default,
programmatic-config, unknown. Used by code that needs to
distinguish “no real source” sentinels from a genuine
Original{FileId(0), …} pointing at a real document.
Sourcepub fn raw(kind: impl Into<String>, data: Value) -> Self
pub fn raw(kind: impl Into<String>, data: Value) -> Self
Escape-hatch constructor for any kind string — including built-in
names and extension-defined kinds (ext/<extension>/<kind>).
Forgery (an extension calling By::raw("shortcode", …) without the
required Invocation anchor) is caught downstream by Plan 6’s
audit-completion test and Plan 7’s debug_assert!. The convention
for third-party kinds is ext/<extension>/<kind>.
Sourcepub fn is_atomic_kind(&self) -> bool
pub fn is_atomic_kind(&self) -> bool
True if a Generated { by: <self>, .. } node should be treated
as atomic by the incremental writer.
Atomic nodes are produced by the pipeline and represent content
the user shouldn’t edit through React (filter constructions,
shortcode resolutions, synthesized title h1, tree-sitter-inserted
spaces). Atomicity is determined by kind alone — orthogonal to
anchor-presence.
Extensions that contribute new by.kind values are not atomic by
default in v1.