#[non_exhaustive]pub enum LineKind {
Para,
Heading {
level: u8,
},
Code {
lang: Option<String>,
},
Island,
Rule,
Unknown {
tag: String,
attrs: Value,
},
}Expand description
The block role of a line. The tree between lines is inferred: two adjacent
lines with equal kind+containers are two blocks of that role (e.g. two
paragraphs), never one.
Open, on the same terms as MarkKind: an unrecognized role round-trips
as LineKind::Unknown and projects as LineKind::Para, so adding a
block construct (a callout, a footnote, a task item) is not a document schema
event, an older reader renders the future construct as a plain paragraph
instead of refusing the whole document, and the opaque tag+attrs still reach a
reader that understands them (DOCUMENT_STORAGE.md § Open vocabularies).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Para
Heading
ATX/Setext heading, level 1..=6.
Code
A line of a code block. lang is the (sanitized) info string, shared by
every line of the same block.
Island
A block-level island: the line’s sole content is one ISLAND_SLOT.
Rule
A thematic break (---/***/___). The line carries no text: the
break is the line itself, parallel to how an island’s content is its
one slot char.
Unknown
Open-set escape hatch: a block role this build does not know,
round-tripped opaque and projected as LineKind::Para. Carries
arbitrary text, like the Para it projects as, so no
LineKindMismatch constrains it.
Implementations§
Source§impl LineKind
impl LineKind
Sourcepub fn projects_as_para(&self) -> bool
pub fn projects_as_para(&self) -> bool
Whether the line projects as a paragraph: LineKind::Para itself, or an
unknown role, which every projection renders as one. For the tests a
match cannot serve: a matches!(kind, Para) that special-cases the
paragraph (suppressing an empty block, say) reads as complete but drops
the open arm, and the two emitters then drift on the construct neither
knows.
An exhaustive match keeps listing both arms, and in this crate the
compiler still polices that: #[non_exhaustive] does not apply within
the defining crate. It does apply to the typst backend, whose emitter
folds both arms into one wildcard; there the ladder, not the compiler,
is what keeps a new role rendering.