Expand description
Content blocks and text representation.
The content layer represents document content as a tree of semantic blocks. This module provides types for all content blocks defined in the Codex specification.
§Content Structure
Content files have a root structure with a version and array of blocks:
use cdx_core::content::{Content, Block, Text};
let content = Content {
version: "0.1".to_string(),
blocks: vec![
Block::heading(1, vec![Text::plain("Hello World")]),
Block::paragraph(vec![Text::plain("This is a paragraph.")]),
],
};§Block Types
Block::Paragraph- Standard paragraphBlock::Heading- Section heading (levels 1-6)Block::List- Ordered or unordered listBlock::ListItem- Item within a listBlock::Blockquote- Quoted contentBlock::CodeBlock- Source code or preformatted textBlock::HorizontalRule- Thematic breakBlock::Image- Embedded or referenced imageBlock::Table- Tabular dataBlock::TableRow- Row within a tableBlock::TableCell- Cell within a rowBlock::Math- Mathematical contentBlock::Break- Line break
§Text and Marks
Text content is represented as Text nodes with optional Marks for formatting:
use cdx_core::content::{Text, Mark};
let bold_text = Text {
value: "Important".to_string(),
marks: vec![Mark::Bold],
};
let link = Text {
value: "Click here".to_string(),
marks: vec![Mark::Link {
href: "https://example.com".to_string(),
title: Some("Example".to_string()),
}],
};Structs§
- Admonition
Block - Admonition block for callout boxes (note, warning, tip, etc.).
- Barcode
Block - Barcode block.
- Barcode
Size - Barcode size specification.
- Block
Attributes - Common attributes that can appear on any block.
- Code
Token - A pre-tokenized syntax highlighting token.
- Content
- Root content structure for a Codex document.
- Definition
List Block - Definition list block.
- Extension
Mark - An extension mark for unsupported or unknown mark types.
- FigCaption
Block - Figure caption block.
- Figure
Block - Figure block (container for images/diagrams with captions).
- Image
Block - Image block content.
- Math
Block - Mathematical content block.
- Measurement
Block - Measurement block for scientific/technical values.
- Signature
Block - Block signature for attestation.
- Signer
Details - Signer details for signatures.
- Subfigure
- A subfigure within a figure.
- SvgBlock
- SVG image block.
- Table
Cell Block - Table cell block content.
- Text
- A text node containing content and optional formatting marks.
- Validation
Error - Content structure validation error.
Enums§
- Admonition
Variant - Admonition variant/type.
- Barcode
Format - Barcode format.
- Block
- A content block in the document tree.
- Block
Signature Type - Type of block-level signature.
- Cell
Align - Cell text alignment.
- Error
Correction Level - Error correction level for barcodes.
- Figure
Numbering - Figure numbering mode.
- Mark
- Formatting marks that can be applied to text.
- Mark
Type - Type identifier for marks (without associated data).
- Math
Format - Mathematical content format.
- Signature
Purpose - Purpose of a signature.
- Uncertainty
Notation - Uncertainty notation format.
- Writing
Mode - Writing mode for text direction.
Functions§
- validate_
content - Validate content structure and rules.