drft/parsers/mod.rs
1//! Text parsers: the link/metadata extractors the text builders wrap.
2//! `markdown` extracts body links; `frontmatter` extracts YAML frontmatter links
3//! and the metadata block.
4
5pub mod frontmatter;
6pub mod markdown;
7
8/// Combined output from parsing a single file: links + optional metadata.
9/// Links are raw strings as they appear in the source — the builder handles
10/// normalization (fragment stripping, anchor filtering, URI detection).
11#[derive(Debug, Clone, Default)]
12pub struct ParseResult {
13 pub links: Vec<String>,
14 /// Structured metadata extracted from the file.
15 pub metadata: Option<serde_json::Value>,
16}
17
18/// Trait implemented by the built-in text parsers.
19pub trait Parser {
20 /// Check whether this parser should run on a given file path.
21 fn matches(&self, path: &str) -> bool;
22 /// Parse a file's content and return discovered links + optional metadata.
23 fn parse(&self, path: &str, content: &str) -> ParseResult;
24}