pub struct Block {Show 13 fields
pub span: Span,
pub attribute_context: Arc<Attributes>,
pub conversion_context: Option<Arc<Attributes>>,
pub id: Option<String>,
pub reftext: Option<Vec<Inline>>,
pub roles: Vec<String>,
pub title: Option<Vec<Inline>>,
pub caption: Option<String>,
pub caption_parts: Vec<AttributePart>,
pub toc: Option<Box<Toc>>,
pub attrs: BlockAttrs,
pub simple: bool,
pub kind: BlockKind,
}Expand description
A block node: its source span, an optional id, and its kind.
id is the block’s anchor — the target a <<id>> resolves to. It comes from
an explicit anchor ([[id]], set by the parser) or, for a section heading
without one, an auto-generated sectids id assigned during the resolve
pass. It is None for any block with no anchor, including an unanchored
document title, and before resolution runs for an auto-id section.
reftext is the inline display text from an explicit [[id,reftext]] anchor;
the resolve pass uses it as a textless reference’s display text (preferring it
over a section’s own title when nonempty). None when no reftext was given.
Block-anchor reftext executes an early attribute stage followed by c/q/r;
even an empty result can retain source reference nodes for editor consumers.
roles are the CSS roles attached by a [.role] / [#id.role1.role2]
shorthand block-attribute line — pure rendering metadata (the HTML backend
emits them as a class), not part of cross-reference resolution. Empty when
none were given. Order is source order.
attrs is the rest of a block-attribute list ([style, name=value, %option]):
the block style, named attributes and %options. id and role are not
here — they fold into id / roles above (the canonical anchor/role
targets), regardless of whether they came from shorthand (#id / .role) or
the longhand (id= / role=). See BlockAttrs.
Fields§
§span: Span§attribute_context: Arc<Attributes>Immutable snapshot of attributes when this block finished parsing. A container sees assignments made while parsing its children; an already completed block keeps its own snapshot. Inline values retain the context in which they were scanned. Shared until an attribute assignment changes the parse context.
conversion_context: Option<Arc<Attributes>>The document attributes when this block converts, which Ruby’s
converter reads (sectanchors, prewrap, toc-placement, …): the
header snapshot with the declarations replayed up to the block and the
effects of earlier conversions, taken on entry before its title and
content. Unlike attribute_context, it has
no reading-only effects (orphan declarations, section-title
expressions). None until conversion visits the block; see
Block::conversion_attributes.
id: Option<String>§reftext: Option<Vec<Inline>>§roles: Vec<String>§title: Option<Vec<Inline>>The block’s title — a .Title line preceding the block (asciidoctor’s
BlockTitleRx). None when the block has no title. The text is parsed
inlines (inline substitutions apply, e.g. .A *bold* caption), so it
carries formatting. The title lives on the Block (not inside
BlockKind) so it survives the type-changing style fixups — a .Title
before a [NOTE]/[example] block stays on the resulting container, not
on the wrapped child.
An unrendered passthrough title keeps its source text unless it was
evaluated during reading for an explicit block ID.
caption: Option<String>The block’s resolved caption — the counter prefix a titled block
carries before its title, e.g. "Example 1. " (note the trailing
space). Filled at parse completion and only for a titled
BlockKind::Example (asciidoctor numbers example blocks via the
example-caption attribute; an untitled example gets no caption and does
not advance the counter). An explicit block/document caption replaces
the prefix without advancing the counter, including an empty caption.
A numbered section’s BlockKind::Heading carries its number prefix
here instead ("1.2. ", "Chapter 3. ", "II: "), computed during
conversion like asciidoctor’s convert_section (sectnumlevels and
the signifiers at the section); backends render it before the inlines.
None for every other block — a titled listing
or paragraph renders its bare title, matching asciidoctor’s unset
listing-caption. Stored pre-rendered, like asciidoctor’s @caption
(#{caption}#{title}): backends prepend it to the title verbatim.
caption_parts: Vec<AttributePart>The caption’s semantic parts when it is not plain text, like the
HTML Ruby stores in @caption: a caption attribute’s formatting or
raw markup (pass:q[*Ex*]), a raw unquoted or substituted
single-quoted caption=, a signifier. Empty when caption is plain
text; caption is always the flat text of these parts.
toc: Option<Box<Toc>>The table of contents this block converts with: a toc::[] block’s
(Ruby’s convert_toc) or a preamble’s with toc-placement=preamble
(convert_preamble). None for other blocks and where Ruby renders
no TOC (<!-- toc disabled --> for the macro).
attrs: BlockAttrs§simple: boolRuby’s :simple content model: a container built from a styled
paragraph ([NOTE]/NOTE:, [example], [sidebar], [open],
[abstract], [partintro], [quote]) holding that paragraph as its
only child. Converters write the paragraph’s inlines directly, without
a paragraph element, like Ruby’s content of a simple block. false
for every delimited or other block.
kind: BlockKindImplementations§
Source§impl Block
impl Block
Sourcepub fn new(span: Span, kind: BlockKind) -> Block
pub fn new(span: Span, kind: BlockKind) -> Block
A block with no anchor: id/reftext default to None and roles /
attrs are empty. The parser fills them in from an explicit [[id]] /
[[id,reftext]] anchor or a [style, #id.role, name=value] attribute
line preceding the block; the resolve pass fills id for an auto-id
section.
Sourcepub fn set_caption(&mut self, parts: Option<Vec<AttributePart>>)
pub fn set_caption(&mut self, parts: Option<Vec<AttributePart>>)
Set the caption from its parts (see caption_parts).
Sourcepub fn conversion_attributes(&self) -> &Attributes
pub fn conversion_attributes(&self) -> &Attributes
The attributes a converter reads for this block: its
conversion_context, else (for a block
conversion did not visit) its reading snapshot.