Skip to main content

quillmark_core/
lib.rs

1//! # Quillmark Core
2//!
3//! Foundational types and traits for the Quillmark schema-driven document
4//! engine: card-yaml block parsing (`~~~` metadata blocks), the [`Quill`]
5//! format bundle and its in-memory file tree, the [`Backend`] trait for output
6//! backends, and structured diagnostics with source-location tracking.
7//!
8//! ```no_run
9//! use quillmark_core::Document;
10//!
11//! // Parse markdown with a card-yaml metadata block
12//! let markdown = "~~~\n$quill: my_quill\n$kind: main\ntitle: Example\n~~~\n\n# Content";
13//! let doc = Document::parse(markdown).unwrap().document;
14//! let title = doc.main()
15//!     .payload()
16//!     .get("title")
17//!     .and_then(|v| v.as_str())
18//!     .unwrap_or("Untitled");
19//! assert_eq!(title, "Example");
20//! ```
21//!
22//! ## Further Reading
23//!
24//! - [markdown-spec.md](https://github.com/borb-sh/quillmark/blob/main/prose/references/markdown-spec.md) - Quillmark Markdown parsing specification
25//! - [Examples](https://github.com/borb-sh/quillmark/tree/main/crates/core/examples) - Working examples
26
27pub mod document;
28pub use document::{
29    Card, CardWire, Document, EditError, Parsed, Payload, PayloadItem, PayloadItemWire,
30    SeedOverlay, WireError,
31};
32
33pub mod writer;
34pub use writer::{CardWriter, TypedWriter};
35
36pub mod reader;
37pub use reader::{CardReader, ReadValue, TypedReader};
38
39pub mod backend;
40pub use backend::{formats_support_canvas, unsupported_format, Backend};
41
42pub mod error;
43pub use error::{
44    Diagnostic, Location, ParseError, RenderError, RenderResult, Severity, YamlError,
45};
46
47pub mod types;
48pub use types::{Artifact, OutputFormat, RenderOptions};
49
50pub mod region;
51pub use region::{
52    doc_path_to_plate_addr, field_boxes, plate_addr_to_doc_path, regions_to_doc_path, ContentHit,
53    HitGranularity, RenderedRegion,
54};
55
56pub mod session;
57pub use session::{
58    ApplyError, Assoc, ChangeBundle, ChangeSet, Delta, IslandOp, LineOp, LiveSession, MarkOp, Op,
59};
60
61/// The canonical content model: re-exported so consumers of the
62/// document mutators ([`Card::overwrite_body`], [`Card::apply_body_change`])
63/// can name the type without depending on `quillmark-content` directly.
64pub use quillmark_content::Content;
65
66pub mod quill;
67pub use quill::{
68    zero_value, BoundParseError, FieldSource, FileTreeNode, Quill, Resolved, ResolvedCard,
69    ResolvedField, ResolvedMain, QuillIgnore, STANDARD_METADATA_KEYS,
70};
71/// The schema model behind [`Quill::config`], and the error
72/// [`QuillConfig::validate_document`] returns. Nameable from the root: reading
73/// a quill's schema, or writing a signature over the validation error, needs no
74/// `quill::` path.
75pub use quill::{CardSchema, FieldSchema, FieldType, QuillConfig, ValidationError};
76
77pub mod value;
78pub use value::{json_depth_exceeds, PathSegment, QuillValue};
79
80pub mod path;
81pub use path::{DocPath, DocSeg};
82
83pub mod normalize;
84
85pub mod version;
86pub use version::{quill_ref_hint, QuillReference, Version, VersionSelector};