pub struct Capabilities {Show 27 fields
pub bold: bool,
pub italic: bool,
pub code: bool,
pub mark: bool,
pub underline: bool,
pub strike: bool,
pub mark_color: bool,
pub superscript: bool,
pub subscript: bool,
pub heading: bool,
pub blockquote: bool,
pub bullet_list: bool,
pub ordered_list: bool,
pub task: bool,
pub link: bool,
pub image: bool,
pub thematic_break: bool,
pub footnote: bool,
pub code_language: bool,
pub table: bool,
pub cell_line_break: bool,
pub alignment: bool,
pub line_spacing: bool,
pub font_size: bool,
pub font_family: bool,
pub text_color: bool,
pub page_break: bool,
}Expand description
Which of leaf’s authoring controls this document’s format can actually spell — one flag per toolbar button, resolved once so a frontend can build its chrome instead of discovering each refusal on a click.
Every field but table is Format::supports_with on the
gesture the matching Doc method calls, so this record cannot drift from
what the ops do; table is [spells_pipe_tables], the one answer twig
doesn’t export.
supports_with rather than supports because two of these are facts about
the parse options as much as about the format. Format::supports answers
for twig’s defaults, and leaf never parses with those — it parses with
[parse_extensions], and a document’s toolbar has to describe the document
it is over. A Markdown editor holding highlight authors ==text==; one
without it would mint bytes its own reparse hands back as plain text, which
is why twig asks before it writes.
The formats are ragged, and that is the point. A single per-document
boolean was enough while the two authorable formats were Markdown and djot
and everything else spelled nothing. HTML is neither: it writes seven of the
eight inline marks as a tag pair, plus <code>, <hr>, an in-cell
<br>, and — since twig 3.4 — a heading or paragraph rebuilt as its tag
pair, and since 3.5 a quote, a list, a code block, a link and an image
printed as fresh nodes; it spells no task box (a form control there) and
no footnote, and its <table> is one twig reads but will not write. So
⌘B, ⌘1 and the quote button work in an HTML document and the task and
table buttons do not, and no one flag can say that. Markdown and djot
differ from each other too:
^superscript^ is djot-only, and an in-cell <br> is Markdown-only.
Fields§
§bold: bool⌘B — InlineKind::Strong.
italic: bool⌘I — InlineKind::Emph.
code: boolInline code — InlineKind::Verbatim.
mark: boolHighlight — InlineKind::Mark. Djot spells it, and so does Markdown
under the highlight extension [parse_extensions] turns on: the
button writes ==text==, which is what the reparse reads back.
underline: bool⌘U — InlineKind::Insert, which every format that marks at all spells.
strike: boolStrikethrough — InlineKind::Delete. Markdown spells GFM’s ~~text~~
out of the box, since twig parses it out of the box.
mark_color: boolThe highlight palette — Doc::set_mark_color. Narrower than
mark and deliberately its own flag: Markdown spells a
colour on a highlight (==🔴 text==) and djot spells only the highlight,
so a toolbar offering the swatches wherever the button lights would offer
them in a document that cannot write one. Pair with
Doc::caret_in_mark, which asks the other question — the palette needs
a highlight to colour as much as a format that spells one.
superscript: bool§subscript: bool§heading: boolHeading levels and “make this a paragraph” — Doc::set_block.
blockquote: bool§bullet_list: bool§ordered_list: bool§task: boolThe checkbox controls: giving an item a box, and ticking one.
link: bool§image: boolCovers Doc::insert_media too — see the note there on why the three
media kinds stand or fall together.
thematic_break: boolThe horizontal-rule button. HTML spells this one (<hr>).
footnote: boolThe footnote button — Doc::insert_footnote. Markdown and djot spell
the pair; HTML has no footnote of its own, so the button goes away rather
than writing brackets that would render as brackets.
code_language: boolSetting a fenced block’s language — a control only ever offered with the caret already in a fence.
table: boolThe grid controls: insert/delete/move a row or column, set a column’s
alignment. Pair with Doc::caret_in_table, which asks the other
question — an HTML <table> holds the caret and still can’t be edited.
cell_line_break: boolShift+Return inside a cell. Markdown and HTML spell it; djot has no idiomatic in-cell break.
alignment: boolThe alignment control — Doc::set_alignment, twig’s
Gesture::SetBlockAttrs. Every format leaf opens but XML spells a
block’s attributes, Markdown under the html_elements
[parse_extensions] turns on (a <div> around the block) and AsciiDoc
through its […] line.
line_spacing: boolThe line-spacing menu — Doc::set_line_spacing. The same gesture as
alignment and so the same answer, and its own flag
because a toolbar dims controls one at a time and the pair may yet
diverge.
font_size: boolThe size menu — Doc::set_font_size, twig’s Gesture::WrapRangeAttrs
over a selection. Narrower than the block pair: AsciiDoc’s
[#id.role]#text# keeps an id and a role and has no slot for a
data- key, so twig refuses the span there and this is false while
alignment is true. The block-level form of the
same property — the caret in a paragraph, no selection — goes through
SetBlockAttrs and still works, which is why the flag describes the
control rather than the caret.
font_family: boolThe face menu — Doc::set_font_family. WrapRangeAttrs, as
font_size is.
text_color: boolThe text-colour swatches — Doc::set_text_color. WrapRangeAttrs,
and not to be confused with mark_color: that is a
highlight’s background and rides the mark node twig already owns,
this is a run’s foreground and rides an attributed span.
page_break: boolThe page-break button — Doc::insert_page_break, twig’s
Gesture::InsertDirective. Markdown under the directives extension
[parse_extensions] turns on (::page-break) and djot, which spells
it as an empty ::: page-break fence.
Those two and no others, though twig spells the gesture in HTML and
AsciiDoc as well — see Capabilities::of.
Implementations§
Source§impl Capabilities
impl Capabilities
Sourcepub fn of(format: Format) -> Self
pub fn of(format: Format) -> Self
Resolve every flag for format, as leaf parses it. Pure and cheap —
twig computes each from a static table — but a frontend that wants to
hold them can.
The extensions are not a parameter because they are not a choice a
caller makes: every leaf document is parsed with [parse_extensions],
so the format is the whole of what varies.
Trait Implementations§
Source§impl Clone for Capabilities
impl Clone for Capabilities
Source§fn clone(&self) -> Capabilities
fn clone(&self) -> Capabilities
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more