pub enum Container {
ListItem {
ordered: bool,
start: u64,
ordinal: u64,
instance: u64,
},
Quote {
instance: u64,
},
}Expand description
A container a line nests inside. The ancestor path is a Vec<Container>.
Closed, on LineKind’s terms: a container outside this set is
ParseError::UnknownName.
Variants§
ListItem
A list item. ordered distinguishes 1. from -; start is the list’s
first number (1 by default); ordinal is this item’s 0-based index in
its list; instance tells this list from an adjacent one of the same
shape (see Container::instance).
Two adjacent lines belong to the same item iff their whole container path is equal. Identity is path plus contiguity: two sibling inner lists under one outer item can produce equal first-item paths, distinguished only by the non-adjacency of their runs.
Quote
A block quote. Adjacent lines sharing one Quote are one
multi-paragraph quote; two adjacent quotes differ in instance.
Implementations§
Source§impl Container
impl Container
Sourcepub fn instance(&self) -> u64
pub fn instance(&self) -> u64
Which instance of its shape this container is, among a run of adjacent siblings that would otherwise be indistinguishable.
Container identity is path plus contiguity, so two adjacent runs of
equal shape read as one: [Quote], [Quote] is one quote, and two
one-item lists are one item spanning two paragraphs. instance is the
one field that exists to break that tie, and it is the whole reason the
encoding is complete rather than a quotient.
A producer writes it against same_run: two adjacent
runs of one shape need distinct values, whatever they are, or they
arrive as one container. Content::normalize collapses those to the
canonical pair — 0, flipping to 1 only where the projection would
otherwise weld the two — so a document needing no
discriminator carries none and one that needs it alternates
0, 1, 0, 1. Non-adjacent runs never collide, so two values suffice.
Sourcepub fn attrs(&self) -> Cow<'_, JsonValue>
pub fn attrs(&self) -> Cow<'_, JsonValue>
The payload bag, one spelling for every member of the vocabulary.
instance is not in it: it is an envelope key, carried on every arm.
Sourcepub fn same_run(&self, other: &Container) -> bool
pub fn same_run(&self, other: &Container) -> bool
Whether these two are the same container shape, ordinal and instance
aside — start counts, so a list starting at 1 and one starting at 3
are two shapes.
The identity rule, read and written alike: two adjacent lines sit in
one container instance iff this holds and their
instances are equal. crate::traverse::runs
applies it, and a producer separates its runs against it. Whether the
projection can then tell two runs apart is
same_weld.
Sourcepub fn same_weld(&self, other: &Container) -> bool
pub fn same_weld(&self, other: &Container) -> bool
Whether the Markdown projection would read two adjacent runs of these
shapes as one — that is, whether the canonical form must spend an
instance to keep them apart.
Content::normalize mints against this;
same_run is what a producer writes against.
Coarser than same_run for lists, because start is invisible in
Markdown: CommonMark reads only a list’s first number, so 1. a
beside 3. b re-imports as one list of two items and the second list’s
start is lost. Comparing ordered alone mints the discriminator
there too, and the marker alternation carries it.