pub enum Block {
Paragraph {
content: Vec<Inline>,
extra: Extra,
},
Heading {
level: u8,
content: Vec<Inline>,
extra: Extra,
},
SceneBreak {
extra: Extra,
},
BlockQuote {
blocks: Vec<Block>,
extra: Extra,
},
Verse {
lines: Vec<Vec<Inline>>,
indents: Vec<u8>,
extra: Extra,
},
Image {
asset: String,
alt: String,
caption: Option<Vec<Inline>>,
width: Option<u8>,
placement: ImagePlacement,
side: ImageSide,
extra: Extra,
},
List {
ordered: bool,
items: Vec<Vec<Block>>,
extra: Extra,
},
Table(Table),
PageBreak {
extra: Extra,
},
}Expand description
Every variant carries extra (unknown fields, see Extra); build
blocks with the constructors below and match with ...
Variants§
Paragraph
Heading
A sub-heading inside a section (rare in fiction). level counts
from the section title: 1 is the first level below it (Markdown
##; in .docx the heading style one below the chapter style).
SceneBreak
BlockQuote
Verse
Lines kept as written; stanzas separated by empty Vecs.
Fields
indents: Vec<u8>The indent level of each line (0 is flush), by position in
lines; empty when no line is indented, and then not written.
May be shorter or longer than lines in a damaged file: read it
through Block::verse_indent, never by index.
Image
Fields
width: Option<u8>Width as a percentage of the text block’s width, 10–100 (the app
offers steps of 5). None: automatic, today’s fit, or 40 % beside
the text. Read through Block::image_width.
placement: ImagePlacementList
Table(Table)
A table (ADR-0011). Its JSON is flat: the table’s own fields and its
extra stand next to "type": "table". Draw it through
Table::layout, never by indexing rows.
PageBreak
Implementations§
Source§impl Block
impl Block
pub fn paragraph(content: Vec<Inline>) -> Self
pub fn heading(level: u8, content: Vec<Inline>) -> Self
pub fn scene_break() -> Self
pub fn block_quote(blocks: Vec<Block>) -> Self
pub fn verse(lines: Vec<Vec<Inline>>) -> Self
Sourcepub fn with_indents(self, levels: Vec<u8>) -> Self
pub fn with_indents(self, levels: Vec<u8>) -> Self
Set the indent level of each line of a verse block, by position in
lines (other blocks are returned unchanged). All zeros is stored as
none, so a verse without indents writes the same JSON as before.
Levels are stored as given and capped on read.
Sourcepub fn verse_indent(&self, line: usize) -> u8
pub fn verse_indent(&self, line: usize) -> u8
The indent level of verse line line: 0 when the block has no level
for it (none stored, a shorter list in a damaged file, a block that
is not verse), at most MAX_VERSE_INDENT; levels beyond the lines
are ignored. Always read the levels through this.
pub fn image( asset: impl Into<String>, alt: impl Into<String>, caption: Option<Vec<Inline>>, ) -> Self
Sourcepub fn with_width(self, percent: u8) -> Self
pub fn with_width(self, percent: u8) -> Self
Set a picture’s width (percent of the text width); other blocks are returned unchanged. The value is stored as given and clamped on read.
pub fn with_placement(self, to: ImagePlacement) -> Self
pub fn with_side(self, to: ImageSide) -> Self
Sourcepub fn image_width(&self) -> Option<u8>
pub fn image_width(&self) -> Option<u8>
A picture’s width as a percentage of the text block, clamped for a
hand-edited file: 10–100, and 25–50 beside the text. None for
automatic width and for other blocks.