pub enum Item {
Heading {
level: u8,
inlines: Vec<Inline>,
label: Option<String>,
label_span: Option<SourceSpan>,
span: SourceSpan,
},
Paragraph {
inlines: Vec<Inline>,
label: Option<String>,
label_span: Option<SourceSpan>,
span: SourceSpan,
},
Set {
kind: DirectiveKind,
name: String,
args: Vec<SetArg>,
span: SourceSpan,
},
RawBlock {
kind: RawBlockKind,
args: Vec<SetArg>,
text: String,
label: Option<String>,
label_span: Option<SourceSpan>,
span: SourceSpan,
},
List {
ordered: bool,
items: Vec<ListItem>,
span: SourceSpan,
},
}Expand description
Top-level construct in a .mos file.
Variants§
Heading
= Title, == Subtitle, === Subsubtitle. A trailing
<label> token after the title attaches to this heading.
Fields
span: SourceSpanParagraph
One or more consecutive non-blank lines that are not a heading
and not a #set block. A leading <label> token (possibly
preceded by ASCII whitespace) attaches to this paragraph.
Set
#set name(...), #image(...), #figure(...). The body is
lexed into typed (key, value) args; semantic validation
(known target/key, type coercion, sanity floors) happens in
the lowerer. kind distinguishes the #set-style configuration
directive from standalone calls like #image and #figure,
which the lowerer dispatches to dedicated paths.
RawBlock
Raw preformatted text or code block. Both forms preserve their long-bracket body as text; the kind leaves room for later styling or language-aware code rendering.
List
A bullet (- ) or numbered (\d+\. ) list. Sibling items at
the same indent are grouped under one list; deeper indents
become nested lists hanging off the most recent item. Numbered
lists always renumber from 1 in MVP: explicit start: N is
deferred.
Implementations§
Source§impl Item
impl Item
Sourcepub fn as_heading(&self) -> Option<(u8, &[Inline], &SourceSpan)>
pub fn as_heading(&self) -> Option<(u8, &[Inline], &SourceSpan)>
Borrow the heading payload if self is Item::Heading.
Sourcepub fn as_paragraph(&self) -> Option<(&[Inline], &SourceSpan)>
pub fn as_paragraph(&self) -> Option<(&[Inline], &SourceSpan)>
Borrow the paragraph payload if self is Item::Paragraph.
Sourcepub fn as_set(&self) -> Option<(&str, &[SetArg], &SourceSpan)>
pub fn as_set(&self) -> Option<(&str, &[SetArg], &SourceSpan)>
Borrow the directive payload if self is Item::Set.
The returned tuple is (name, args, span); the caller can also
reach DirectiveKind via Self::directive_kind. The
accessor name is retained for back-compat; every existing
caller pre-dates the #image/#figure directives and only
looks at name/args/span.
Sourcepub fn as_raw_block(&self) -> Option<RawBlockView<'_>>
pub fn as_raw_block(&self) -> Option<RawBlockView<'_>>
Borrow the raw block payload if self is Item::RawBlock.
Sourcepub fn directive_kind(&self) -> Option<DirectiveKind>
pub fn directive_kind(&self) -> Option<DirectiveKind>
Borrow the DirectiveKind tag if self is Item::Set.
Sourcepub fn as_list(&self) -> Option<(bool, &[ListItem], &SourceSpan)>
pub fn as_list(&self) -> Option<(bool, &[ListItem], &SourceSpan)>
Borrow the list payload if self is Item::List. The
returned tuple is (ordered, items, span).
Sourcepub fn label(&self) -> Option<&str>
pub fn label(&self) -> Option<&str>
Borrow the explicit <label> attached to this block, if any.
Returns None for Item::Set and Item::List (label
syntax is not yet defined on those blocks).
Sourcepub fn label_span(&self) -> Option<&SourceSpan>
pub fn label_span(&self) -> Option<&SourceSpan>
Borrow the source span covering only the label token text, if any.
The delimiters (<, >, or directive string quotes) are excluded so a
structured suggestion can replace just the label bytes.