Expand description
§Generic AST types that support user-defined data Generic Abstract Syntax Tree (AST) for CommonMark + GitHub Flavored Markdown (GFM)
This module provides generic versions of all AST structures that allow attaching
user-defined data to any AST node. The generic parameter T represents the type
of user data that can be associated with each element.
§Features
- Zero-cost abstraction: When
T = (), no additional memory is used - Flexible user data: Support for any user-defined type
- Serde compatibility: Proper serialization with optional user data fields
- Type safety: Compile-time guarantees about data presence
§Examples
use markdown_ppp::ast::generic::*;
// AST without user data (equivalent to regular AST)
type SimpleDocument = Document<()>;
// AST with element IDs
#[derive(Debug, Clone, PartialEq)]
struct ElementId(u32);
type DocumentWithIds = Document<ElementId>;
// AST with source information
#[derive(Debug, Clone, PartialEq)]
struct SourceInfo {
line: u32,
column: u32,
}
type DocumentWithSource = Document<SourceInfo>;Re-exports§
pub use super::Alignment;pub use super::CodeBlockKind;pub use super::GitHubAlert;pub use super::GitHubAlertType;pub use super::HeadingKind;pub use super::ListBulletKind;pub use super::ListOrderedKindOptions;pub use super::SetextHeading;pub use super::TaskState;
Structs§
- Code
Block - Fenced or indented code block.
- Document
- Root of a Markdown document with optional user data
- Footnote
Definition - Footnote definition block (e.g.,
[^label]: content). - GitHub
Alert Node - GitHub alert block with user data support
- Heading
- Heading with level 1–6 and inline content.
- Image
- Re‑usable structure for images.
- Link
- Re‑usable structure for links and images (destination + children).
- Link
Definition - Link reference definition (GFM) with a label, destination and optional title.
- Link
Reference - Reference-style link (e.g.,
[text][label]or[label][]). - List
- A list container — bullet or ordered.
- List
Item - Item within a list.
- Table
- A table is a collection of rows and columns with optional alignment. The first row is the header row.
Enums§
- Block
- Block‑level constructs in the order they appear in the CommonMark spec.
- Inline
- Inline-level elements within paragraphs, headings, and other blocks.
- List
Kind - Specifies what kind of list we have.