Skip to main content

Item

Enum Item 

Source
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

§level: u8
§inlines: Vec<Inline>
§label_span: Option<SourceSpan>
§span: SourceSpan
§

Paragraph

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.

Fields

§inlines: Vec<Inline>
§label_span: Option<SourceSpan>
§span: SourceSpan
§

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.

Fields

§name: String
§args: Vec<SetArg>
§span: SourceSpan
§

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.

Fields

§args: Vec<SetArg>
§text: String
§label_span: Option<SourceSpan>
§span: SourceSpan
§

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.

Fields

§ordered: bool
§items: Vec<ListItem>
§span: SourceSpan

Implementations§

Source§

impl Item

Source

pub fn as_heading(&self) -> Option<(u8, &[Inline], &SourceSpan)>

Borrow the heading payload if self is Item::Heading.

Source

pub fn as_paragraph(&self) -> Option<(&[Inline], &SourceSpan)>

Borrow the paragraph payload if self is Item::Paragraph.

Source

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.

Source

pub fn as_raw_block(&self) -> Option<RawBlockView<'_>>

Borrow the raw block payload if self is Item::RawBlock.

Source

pub fn directive_kind(&self) -> Option<DirectiveKind>

Borrow the DirectiveKind tag if self is Item::Set.

Source

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).

Source

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).

Source

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.

Trait Implementations§

Source§

impl Clone for Item

Source§

fn clone(&self) -> Item

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Item

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Item

§

impl RefUnwindSafe for Item

§

impl Send for Item

§

impl Sync for Item

§

impl Unpin for Item

§

impl UnsafeUnpin for Item

§

impl UnwindSafe for Item

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.