pub enum Block {
Show 25 variants
Paragraph {
id: Option<String>,
children: Vec<Text>,
attributes: BlockAttributes,
},
Heading {
id: Option<String>,
level: u8,
children: Vec<Text>,
attributes: BlockAttributes,
},
List {
id: Option<String>,
ordered: bool,
start: Option<u32>,
children: Vec<Block>,
attributes: BlockAttributes,
},
ListItem {
id: Option<String>,
checked: Option<bool>,
children: Vec<Block>,
attributes: BlockAttributes,
},
Blockquote {
id: Option<String>,
children: Vec<Block>,
attributes: BlockAttributes,
},
CodeBlock {
id: Option<String>,
language: Option<String>,
highlighting: Option<String>,
tokens: Option<Vec<CodeToken>>,
children: Vec<Text>,
attributes: BlockAttributes,
},
HorizontalRule {
id: Option<String>,
},
Image(ImageBlock),
Table {
id: Option<String>,
children: Vec<Block>,
attributes: BlockAttributes,
},
TableRow {
id: Option<String>,
header: bool,
children: Vec<Block>,
attributes: BlockAttributes,
},
TableCell(TableCellBlock),
Math(MathBlock),
Break {
id: Option<String>,
},
DefinitionList(DefinitionListBlock),
DefinitionItem {
id: Option<String>,
children: Vec<Block>,
attributes: BlockAttributes,
},
DefinitionTerm {
id: Option<String>,
children: Vec<Text>,
attributes: BlockAttributes,
},
DefinitionDescription {
id: Option<String>,
children: Vec<Block>,
attributes: BlockAttributes,
},
Measurement(MeasurementBlock),
Signature(SignatureBlock),
Svg(SvgBlock),
Barcode(BarcodeBlock),
Figure(FigureBlock),
FigCaption(FigCaptionBlock),
Admonition(AdmonitionBlock),
Extension(ExtensionBlock),
}Expand description
A content block in the document tree.
Blocks are the structural elements of a document, containing either other blocks (containers) or text content (leaves).
§Serialization
Blocks serialize as JSON objects with a "type" field. Core block types
use camelCase names (e.g., "paragraph", "codeBlock"). Extension blocks
use colon-delimited types (e.g., "forms:textInput", "academic:theorem").
Variants§
Paragraph
Standard paragraph block.
Fields
attributes: BlockAttributesBlock attributes.
Heading
Section heading (levels 1-6).
Fields
attributes: BlockAttributesBlock attributes.
List
Ordered or unordered list.
Fields
attributes: BlockAttributesBlock attributes.
ListItem
Item within a list.
Fields
attributes: BlockAttributesBlock attributes.
Blockquote
Quoted content block.
Fields
attributes: BlockAttributesBlock attributes.
CodeBlock
Source code or preformatted text.
Fields
attributes: BlockAttributesBlock attributes.
HorizontalRule
Thematic break between sections.
Image(ImageBlock)
Embedded or referenced image.
Table
Tabular data.
Fields
attributes: BlockAttributesBlock attributes.
TableRow
Row within a table.
Fields
attributes: BlockAttributesBlock attributes.
TableCell(TableCellBlock)
Cell within a table row.
Math(MathBlock)
Mathematical content.
Break
Line break within a block.
DefinitionList(DefinitionListBlock)
Definition list.
DefinitionItem
Definition item (term + description pair).
Fields
attributes: BlockAttributesBlock attributes.
DefinitionTerm
Definition term.
Fields
attributes: BlockAttributesBlock attributes.
DefinitionDescription
Definition description.
Fields
attributes: BlockAttributesBlock attributes.
Measurement(MeasurementBlock)
Scientific/technical measurement.
Signature(SignatureBlock)
Block-level signature.
Svg(SvgBlock)
SVG image.
Barcode(BarcodeBlock)
Barcode (QR, Data Matrix, etc.).
Figure(FigureBlock)
Figure container.
FigCaption(FigCaptionBlock)
Figure caption.
Admonition(AdmonitionBlock)
Admonition block (note, warning, tip, etc.).
Extension(ExtensionBlock)
Extension block for custom/unknown block types.
Extension blocks use namespaced types like “forms:textInput” or “semantic:citation”. When parsing, unknown types are preserved as extension blocks with their raw attributes intact.
Implementations§
Source§impl Block
impl Block
Sourcepub fn unordered_list(items: Vec<Block>) -> Self
pub fn unordered_list(items: Vec<Block>) -> Self
Create an unordered list.
Sourcepub fn ordered_list(items: Vec<Block>) -> Self
pub fn ordered_list(items: Vec<Block>) -> Self
Create an ordered list.
Sourcepub fn blockquote(children: Vec<Block>) -> Self
pub fn blockquote(children: Vec<Block>) -> Self
Create a blockquote.
Sourcepub fn code_block(code: impl Into<String>, language: Option<String>) -> Self
pub fn code_block(code: impl Into<String>, language: Option<String>) -> Self
Create a code block.
Sourcepub fn horizontal_rule() -> Self
pub fn horizontal_rule() -> Self
Create a horizontal rule.
Sourcepub fn table_cell(children: Vec<Text>) -> Self
pub fn table_cell(children: Vec<Text>) -> Self
Create a table cell.
Sourcepub fn math(value: impl Into<String>, format: MathFormat, display: bool) -> Self
pub fn math(value: impl Into<String>, format: MathFormat, display: bool) -> Self
Create a math block.
Sourcepub fn line_break() -> Self
pub fn line_break() -> Self
Create a line break.
Sourcepub fn definition_list(items: Vec<Block>) -> Self
pub fn definition_list(items: Vec<Block>) -> Self
Create a definition list.
Sourcepub fn definition_item(children: Vec<Block>) -> Self
pub fn definition_item(children: Vec<Block>) -> Self
Create a definition item.
Sourcepub fn definition_term(children: Vec<Text>) -> Self
pub fn definition_term(children: Vec<Text>) -> Self
Create a definition term.
Sourcepub fn definition_description(children: Vec<Block>) -> Self
pub fn definition_description(children: Vec<Block>) -> Self
Create a definition description.
Sourcepub fn measurement(value: f64, display: impl Into<String>) -> Self
pub fn measurement(value: f64, display: impl Into<String>) -> Self
Create a measurement block.
Sourcepub fn signature(signature_type: BlockSignatureType) -> Self
pub fn signature(signature_type: BlockSignatureType) -> Self
Create a signature block.
Sourcepub fn svg_from_src(src: impl Into<String>) -> Self
pub fn svg_from_src(src: impl Into<String>) -> Self
Create an SVG block from a source reference.
Sourcepub fn svg_from_content(content: impl Into<String>) -> Self
pub fn svg_from_content(content: impl Into<String>) -> Self
Create an SVG block from inline content.
Sourcepub fn barcode(
format: BarcodeFormat,
data: impl Into<String>,
alt: impl Into<String>,
) -> Self
pub fn barcode( format: BarcodeFormat, data: impl Into<String>, alt: impl Into<String>, ) -> Self
Create a barcode block.
Sourcepub fn figcaption(children: Vec<Text>) -> Self
pub fn figcaption(children: Vec<Text>) -> Self
Create a figure caption.
Sourcepub fn admonition(variant: AdmonitionVariant, children: Vec<Block>) -> Self
pub fn admonition(variant: AdmonitionVariant, children: Vec<Block>) -> Self
Create an admonition block.
Sourcepub fn block_type(&self) -> Cow<'_, str>
pub fn block_type(&self) -> Cow<'_, str>
Get the block type as a string.
For core blocks, returns the camelCase type name.
For extension blocks, returns the colon-delimited type (e.g., "forms:textInput").
Sourcepub fn extension(
namespace: impl Into<String>,
block_type: impl Into<String>,
) -> Self
pub fn extension( namespace: impl Into<String>, block_type: impl Into<String>, ) -> Self
Create an extension block.
Sourcepub fn is_extension(&self) -> bool
pub fn is_extension(&self) -> bool
Check if this is an extension block.
Sourcepub fn as_extension(&self) -> Option<&ExtensionBlock>
pub fn as_extension(&self) -> Option<&ExtensionBlock>
Get the extension block if this is one.