cdx_core/content/mod.rs
1//! Content blocks and text representation.
2//!
3//! The content layer represents document content as a tree of semantic blocks.
4//! This module provides types for all content blocks defined in the Codex specification.
5//!
6//! # Content Structure
7//!
8//! Content files have a root structure with a version and array of blocks:
9//!
10//! ```rust
11//! use cdx_core::content::{Content, Block, Text};
12//!
13//! let content = Content {
14//! version: "0.1".to_string(),
15//! blocks: vec![
16//! Block::heading(1, vec![Text::plain("Hello World")]),
17//! Block::paragraph(vec![Text::plain("This is a paragraph.")]),
18//! ],
19//! };
20//! ```
21//!
22//! # Block Types
23//!
24//! - [`Block::Paragraph`] - Standard paragraph
25//! - [`Block::Heading`] - Section heading (levels 1-6)
26//! - [`Block::List`] - Ordered or unordered list
27//! - [`Block::ListItem`] - Item within a list
28//! - [`Block::Blockquote`] - Quoted content
29//! - [`Block::CodeBlock`] - Source code or preformatted text
30//! - [`Block::HorizontalRule`] - Thematic break
31//! - [`Block::Image`] - Embedded or referenced image
32//! - [`Block::Table`] - Tabular data
33//! - [`Block::TableRow`] - Row within a table
34//! - [`Block::TableCell`] - Cell within a row
35//! - [`Block::Math`] - Mathematical content
36//! - [`Block::Break`] - Line break
37//!
38//! # Text and Marks
39//!
40//! Text content is represented as [`Text`] nodes with optional [`Mark`]s for formatting:
41//!
42//! ```rust
43//! use cdx_core::content::{Text, Mark};
44//!
45//! let bold_text = Text {
46//! value: "Important".to_string(),
47//! marks: vec![Mark::Bold],
48//! };
49//!
50//! let link = Text {
51//! value: "Click here".to_string(),
52//! marks: vec![Mark::Link {
53//! href: "https://example.com".to_string(),
54//! title: Some("Example".to_string()),
55//! }],
56//! };
57//! ```
58
59mod block;
60mod text;
61mod validation;
62
63pub use block::{
64 AdmonitionBlock, AdmonitionVariant, BarcodeBlock, BarcodeFormat, BarcodeSize, Block,
65 BlockAttributes, BlockSignatureType, CellAlign, CodeToken, Content, DefinitionListBlock,
66 ErrorCorrectionLevel, FigCaptionBlock, FigureBlock, FigureNumbering, ImageBlock, MathBlock,
67 MathFormat, MeasurementBlock, SignatureBlock, SignaturePurpose, SignerDetails, Subfigure,
68 SvgBlock, TableCellBlock, UncertaintyNotation, WritingMode,
69};
70pub use text::{ExtensionMark, Mark, MarkType, Text};
71pub use validation::{validate_content, ValidationError};