Skip to main content

Module document

Module document 

Source
Expand description

§Document Module

Parsing functionality for markdown documents with YAML frontmatter.

§Overview

The document module provides the Document::from_markdown function for parsing markdown documents into a typed in-memory model.

§Key Types

  • Document: Typed in-memory Quillmark document — main card plus composable cards.
  • Card: A single metadata fence block, main or composable, with a sentinel, typed frontmatter, and a body.
  • Sentinel: Discriminates QUILL: main cards from CARD: composable cards.
  • Frontmatter: Ordered list of items (fields + comments) parsed from a YAML fence.

§Examples

§Basic Parsing

use quillmark_core::Document;

let markdown = r#"---
QUILL: my_quill
title: My Document
author: John Doe
---


Document content here.
"#;

let doc = Document::from_markdown(markdown).unwrap();
let title = doc.main()
    .frontmatter()
    .get("title")
    .and_then(|v| v.as_str())
    .unwrap_or("Untitled");
assert_eq!(title, "My Document");
assert_eq!(doc.cards().len(), 0);

§Accessing the plate wire format

use quillmark_core::Document;

let doc = Document::from_markdown(
    "---\nQUILL: my_quill\ntitle: Hi\n---\n\nBody here.\n"
).unwrap();
let json = doc.to_plate_json();
assert_eq!(json["QUILL"], "my_quill");
assert_eq!(json["title"], "Hi");
assert_eq!(json["BODY"], "\nBody here.\n");
assert!(json["CARDS"].is_array());

§Error Handling

Document::from_markdown returns errors for:

  • Malformed YAML syntax
  • Unclosed frontmatter blocks
  • Multiple global frontmatter blocks
  • Both QUILL and CARD specified in the same block
  • Reserved field name usage
  • Name collisions

See PARSE.md for comprehensive documentation of the Extended YAML Metadata Standard.

Re-exports§

pub use edit::EditError;
pub use frontmatter::Frontmatter;
pub use frontmatter::FrontmatterItem;

Modules§

assemble
Assembly of fences and sentinels into a Document.
edit
Document Editor Surface
emit
Canonical Markdown emission for Document.
fences
Line-oriented fence scanner for Quillmark Markdown.
frontmatter
Ordered frontmatter representation.
limits
Size and depth budget constants for document parsing.
prescan
Pre-scan of a metadata fence’s YAML content to recover features that serde_saphyr discards.
sentinel
QUILL / CARD sentinel extraction and reserved-name validation.

Structs§

Card
A single metadata fence parsed from a Quillmark Markdown document.
Document
A fully-parsed, typed in-memory Quillmark document.
ParseOutput
Parse result carrying both the parsed document and any non-fatal warnings (e.g. near-miss sentinel lints emitted per spec §4.2).

Enums§

Sentinel
Discriminator for a Card’s metadata fence.