Skip to main content

Module content

Module content 

Source
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

§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§

AdmonitionBlock
Admonition block for callout boxes (note, warning, tip, etc.).
BarcodeBlock
Barcode block.
BarcodeSize
Barcode size specification.
BlockAttributes
Common attributes that can appear on any block.
CodeToken
A pre-tokenized syntax highlighting token.
Content
Root content structure for a Codex document.
DefinitionListBlock
Definition list block.
ExtensionMark
An extension mark for unsupported or unknown mark types.
FigCaptionBlock
Figure caption block.
FigureBlock
Figure block (container for images/diagrams with captions).
ImageBlock
Image block content.
MathBlock
Mathematical content block.
MeasurementBlock
Measurement block for scientific/technical values.
SignatureBlock
Block signature for attestation.
SignerDetails
Signer details for signatures.
Subfigure
A subfigure within a figure.
SvgBlock
SVG image block.
TableCellBlock
Table cell block content.
Text
A text node containing content and optional formatting marks.
ValidationError
Content structure validation error.

Enums§

AdmonitionVariant
Admonition variant/type.
BarcodeFormat
Barcode format.
Block
A content block in the document tree.
BlockSignatureType
Type of block-level signature.
CellAlign
Cell text alignment.
ErrorCorrectionLevel
Error correction level for barcodes.
FigureNumbering
Figure numbering mode.
Mark
Formatting marks that can be applied to text.
MarkType
Type identifier for marks (without associated data).
MathFormat
Mathematical content format.
SignaturePurpose
Purpose of a signature.
UncertaintyNotation
Uncertainty notation format.
WritingMode
Writing mode for text direction.

Functions§

validate_content
Validate content structure and rules.