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§

Frontmatter
What a document’s leading --- block turned out to be.
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.
frontmatter_parts
The frontmatter block and the body of a document, both borrowed, or None when the document carries no closed frontmatter (no opening fence on its first line, or an opening fence never closed). The one entry point every reader outside this module uses; the contract is split_frontmatter_core’s: a byte-order mark is skipped, CRLF and LF documents both split, the fence counts only at the start of the document, and the body starts after the closing fence’s line break.
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.
split_frontmatter_core
Split a document at its frontmatter delimiters.