sim_codec_doc/lib.rs
1//! Markup document domain codec for SIM.
2//!
3//! Provides `codec:doc`, a domain decoder/encoder pair that turns document text
4//! into a semantic markup document `Expr` and back, strict
5//! `codec:markup/<id>` backends for Markdown, Typst, AsciiDoc, and LaTeX, and
6//! provenance-preserving chunk operations exposed as callable functions.
7//! As a domain codec it round-trips only documents and chunks and fails closed
8//! outside that domain.
9//!
10//! Module map (all modules are private; the public surface is re-exported from
11//! this crate root):
12//! - backend: the `MarkupBackend` trait, deterministic `BackendRegistry`, and
13//! fidelity/error contracts for backend implementations.
14//! - catalog: the implemented/tracked backend catalog for markup formats.
15//! - codec: the `DocCodec` decoder/encoder, the `DocCodecLib` host lib, and
16//! `install_doc_codec` plus `codec:markup/<id>` installation.
17//! - document: compatibility chunking wrappers (`DocValue`, `DocFormat`,
18//! `DocBlock`, `DocChunk`, `ChunkOp`), `decode_document`, and `chunk`.
19//! - edit: reversible document-domain edits over `MarkupDoc`.
20//! - markup: the shared semantic markup IR (`MarkupDoc`, `MarkupBlock`,
21//! `Inline`) and its ordinary-data projection.
22//! - functions: the `doc/chunk-*` chunking functions registered as callables.
23//! - asciidoc: the `asciidork-parser` AsciiDoc backend.
24//! - latex: the `codebook-tree-sitter-latex` LaTeX backend.
25//! - markdown: the `pulldown-cmark` Markdown backend.
26//! - typst_backend: the `typst-syntax` Typst backend.
27
28#![forbid(unsafe_code)]
29#![deny(missing_docs)]
30
31mod asciidoc;
32#[cfg(test)]
33mod asciidoc_tests;
34mod backend;
35mod catalog;
36#[cfg(test)]
37mod catalog_tests;
38mod codec;
39mod document;
40mod edit;
41#[cfg(test)]
42mod edit_tests;
43mod functions;
44mod html;
45mod latex;
46#[cfg(test)]
47mod latex_tests;
48mod markdown;
49mod markdown_writer;
50mod markup;
51#[cfg(test)]
52mod tests;
53mod typst_backend;
54
55/// Cookbook recipes embedded from this crate's `recipes/` directory.
56pub static RECIPES: sim_cookbook::EmbeddedDir =
57 include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));
58
59pub use asciidoc::AsciiDocBackend;
60pub use backend::{
61 BackendRegistry, BasicMarkdownBackend, MarkupBackend, MarkupDecodeOptions, MarkupEncodeOptions,
62 MarkupError, MarkupFidelity, MarkupLoss, default_backend_registry,
63};
64pub use catalog::{BackendInfo, BackendStatus, backend_catalog};
65pub use codec::{
66 DocCodec, DocCodecLib, MARKUP_CODEC_PREFIX, MarkupCodec, install_doc_codec,
67 install_markup_codecs, markup_codec_symbol,
68};
69pub use document::{
70 ChunkOp, DocBlock, DocBlockKind, DocChunk, DocFormat, DocValue, chunk, decode_document,
71};
72pub use edit::{MarkupEdit, apply_edit, invert_edit};
73pub use html::{HtmlBackend, HtmlDecodeOptions, decode_html_bytes};
74pub use latex::LatexBackend;
75pub use markdown::{
76 AttributeEnvelope, DialectMarkdownBackend, LinkDialect, MarkdownBackend, MarkdownDialect,
77};
78pub use markup::{
79 BackendId, Inline, MarkupBlock, MarkupDoc, MathSource, SourceDoc, Span, SpanState,
80 decode_markup_doc,
81};
82pub use typst_backend::TypstBackend;