Skip to main content

Module parser

Module parser 

Source
Expand description

Markdown → Entity parser. Handles YAML frontmatter, sections, wiki-links.

Key design decisions:

  • Hand-rolled YAML frontmatter parser (NOT serde_yaml) to match JS type coercion
  • Code blocks are masked before section/link detection to prevent false matches
  • The parser is schema-aware: it uses the schema to determine catch-all sections

Re-exports§

pub use crate::markdown::mask_code_blocks;
pub use crate::markdown::mask_code_blocks_and_spans;

Enums§

ParseError

Functions§

body_after_frontmatter
Return the body slice after a leading --- frontmatter block, or the whole input when no frontmatter is present. Mirrors the offset arithmetic in [split_frontmatter] but borrows rather than allocating — a scan needs to read, not own.
compute_hash
Compute SHA-256 hash of content, truncated to 16 hex characters.
extract_inline_links_lenient
Permissive sibling of [extract_inline_links] for read-side scanners. Decodes every [[...]] token via wiki_link_to_id_lenient so on-disk drift (legacy entities, archive-imports from pre-strict engines, partial-mutation rollbacks) keeps flowing through dangling- link reporters and graph inspectors. Mutation paths MUST NOT use this helper — see [extract_inline_links] for the strict variant.
has_merge_conflict_markers
True when text — a whole entity file — carries a complete git merge-conflict block: an ordered <<<<<<< … / ======= / >>>>>>> … triple at line starts.
parse_file
Parse an entity from a file on disk.
parse_markdown
Parse a markdown string into an Entity.
peek_title_and_type
Peek the entity title (first # heading in the body) and type (type: frontmatter field) from raw markdown without running the full schema-aware parser. Used by surfaces that read a markdown blob outside the in-memory store — e.g. memstead_diff walking git trees between two arbitrary refs, where the store snapshot (current HEAD) is not a valid source for a non-HEAD ref. Returns None for title when the body carries no # heading and None for entity_type when the frontmatter lacks a non-empty type:.
peek_type_from_frontmatter
Extract the type: value from frontmatter without running the full parser.