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 RichtextDecodeError, 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, Backend};
41
42pub mod error;
43pub use error::{Diagnostic, Location, ParseError, RenderError, RenderResult, Severity};
44
45pub mod types;
46pub use types::{Artifact, OutputFormat, RenderOptions};
47
48pub mod region;
49pub use region::{
50 doc_path_to_plate_addr, field_boxes, plate_addr_to_doc_path, ContentHit, HitGranularity,
51 RenderedRegion,
52};
53
54pub mod session;
55pub use session::{ApplyError, Assoc, ChangeSet, Delta, LineOp, LiveSession, MarkOp, Op};
56
57/// The canonical content model — re-exported so consumers of the
58/// document mutators ([`Card::install_body`], [`Card::apply_body_change`])
59/// can name the type without depending on `quillmark-content` directly.
60pub use quillmark_content::Content;
61
62pub mod quill;
63pub use quill::{
64 zero_value, FieldSource, FileTreeNode, Quill, Resolved, ResolvedCard, ResolvedField, ResolvedMain,
65 QuillIgnore, STANDARD_METADATA_KEYS,
66};
67
68pub mod value;
69pub use value::{json_depth_exceeds, PathSegment, QuillValue};
70
71pub mod path;
72pub use path::{DocPath, DocSeg};
73
74pub mod normalize;
75
76pub mod version;
77pub use version::{quill_ref_hint, QuillReference, Version, VersionSelector};