pub enum Align {
Center,
Right,
Justify,
}Expand description
How a block’s lines are set across the measure — the one presentation
property an author reaches for before any other, and the only one of the
six whose vocabulary is a class rather than a data- key.
A class is a space-separated token list in every format leaf opens, and
this reads the one token it knows and leaves the rest: a paragraph that
arrives as class="lead center" is centred and keeps lead. A token
outside the vocabulary is not an error — it is somebody else’s class, and a
document from elsewhere passes through the editor unharmed.
There is no Left, because absence is left: the default alignment is the
theme’s, and a document that agrees with it has no reason to say so. A
right-to-left default is a theme matter, not a class.
Variants§
Implementations§
Source§impl Align
impl Align
Sourcepub const ALL: [Self; 3]
pub const ALL: [Self; 3]
Every alignment, in the order a toolbar offers them. Left is absent
because absence is left; a segmented control draws a fourth segment
for it and calls crate::Doc::set_alignment with None.
Sourcepub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
pub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>
The alignment a block’s attributes name, if any — the first token of
class that is one of the three, in source order.
Takes the attribute list rather than the node for MarkColor’s
reason: this module stays free of twig as well as of any toolkit, and
both the block walker and the caret query hand over the same
node.attrs.
Sourcepub fn from_token(token: &str) -> Option<Self>
pub fn from_token(token: &str) -> Option<Self>
Read one class token. None for a token outside the vocabulary,
which is how a foreign class is kept rather than misread — the
gesture that rewrites the alignment removes only the tokens this
answers Some for.
Sourcepub const fn name(self) -> &'static str
pub const fn name(self) -> &'static str
The token twig spells it with, and what from_token
reads back — also the class a frontend’s stylesheet selects on, which is
why it is CSS’s own word for the same thing.
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
This alignment’s position in ALL — the index a frontend’s
own segmented control is keyed by, the way MarkColor::index keys a
palette.