Skip to main content

Align

Enum Align 

Source
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§

§

Center

§

Right

§

Justify

Implementations§

Source§

impl Align

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Align

Source§

fn clone(&self) -> Align

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Align

Source§

impl Debug for Align

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Align

Source§

impl PartialEq for Align

Source§

fn eq(&self, other: &Align) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Align

Auto Trait Implementations§

§

impl Freeze for Align

§

impl RefUnwindSafe for Align

§

impl Send for Align

§

impl Sync for Align

§

impl Unpin for Align

§

impl UnsafeUnpin for Align

§

impl UnwindSafe for Align

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.