ndg_commonmark/
types.rs

1//! Types for ndg-commonmark public API and internal use.
2use serde::{Deserialize, Serialize};
3
4/// Represents a header in a Markdown document.
5#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
6pub struct Header {
7  /// Header text (inline content, no markdown formatting).
8  pub text:  String,
9  /// Header level (1-6).
10  pub level: u8,
11  /// Generated or explicit anchor ID for the header.
12  pub id:    String,
13}
14
15/// Represents a file that was included via `{=include=}` directive.
16#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
17pub struct IncludedFile {
18  /// Path to the included file.
19  pub path:          String,
20  /// Optional custom output path from `html:into-file` directive.
21  pub custom_output: Option<String>,
22}
23
24/// Result of Markdown processing.
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
26pub struct MarkdownResult {
27  /// Rendered HTML output.
28  pub html: String,
29
30  /// Extracted headers (for `ToC`, navigation, etc).
31  pub headers: Vec<Header>,
32
33  /// Title of the document, if found (usually first H1).
34  pub title: Option<String>,
35
36  /// Files that were included via `{=include=}` directives.
37  pub included_files: Vec<IncludedFile>,
38}