Skip to main content

MarkupMode

Enum MarkupMode 

Source
pub enum MarkupMode {
    None,
    Shortcuts,
    Full,
}
Expand description

How much of the source markup the WYSIWYG view exposes — a per-editor preference, orthogonal to View. Named for markup rather than for Markdown because leaf is grammar-agnostic: twig hands it Djot, HTML and XML on the same terms, and every rung below is about delimiters, whatever grammar spells them. The examples are Markdown only because that is what most documents are.

A single ladder over two underlying axes, because only three of their four combinations are coherent:

authoring offauthoring on
delimiters hiddenNoneShortcuts
caret line revealedincoherentFull

The empty quadrant would show delimiters on the caret’s line and then escape the ones you type — a surface that displays a syntax it refuses to accept. Someone who wants to read raw markup without authoring it has View::Source, which is the better tool for it.

The two axes are read separately by the code that cares — see reveals_caret_line and authors — so neither behaviour has to know it’s spelled as a ladder.

Variants§

§

None

Delimiters stay hidden even on the caret’s line, and typed syntax stays literal — twig escapes anything that would open markup, so formatting comes from commands (⌘b, the toolbar) instead of from spelling. The clean reading surface for people who don’t write markup by hand; the default, and what Diaryx ships.

§

Shortcuts

Delimiters stay hidden, but typing them authors real markup: *x* becomes italic and the asterisks disappear into the styling (Typora/Bear-shaped). For someone who knows the syntax but wants the clean surface back once it has been applied.

§

Full

The caret’s line shows its raw markup while every other line renders resolved (Obsidian live-preview-shaped), and typed syntax authors markup — for people fluent in the document’s grammar who want to see and edit the delimiters they type.

Implementations§

Source§

impl MarkupMode

Source

pub fn reveals_caret_line(self) -> bool

Whether the rich view shows raw delimiters on the line holding the caret. The rendering axis — read by Doc::reveal_line and threaded into the WYSIWYG builder.

Source

pub fn authors(self) -> bool

Whether typed markup characters author real formatting. The editing axis — read by Doc::insert, which escapes typed syntax when this is false.

Trait Implementations§

Source§

impl Clone for MarkupMode

Source§

fn clone(&self) -> MarkupMode

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 MarkupMode

Source§

impl Debug for MarkupMode

Source§

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

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

impl Default for MarkupMode

Source§

fn default() -> MarkupMode

Returns the “default value” for a type. Read more
Source§

impl Eq for MarkupMode

Source§

impl PartialEq for MarkupMode

Source§

fn eq(&self, other: &MarkupMode) -> 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 MarkupMode

Auto Trait Implementations§

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.