Skip to main content

Crate moss_core

Crate moss_core 

Source
Expand description

moss-core: Pure Rust content processing.

Zero I/O, zero async. Takes strings in, returns strings out. All filesystem access happens in the Tauri layer.

Panic-free contract: Every public function in moss-core is invoked from Tauri command handlers in the host process. The host is configured with panic = "abort" for release builds, so any panic on user input crashes the whole desktop app (see fix in date.rs for the editor-mount panic on Chinese filenames). Treat moss-core as panic-free on user input: never unwrap/expect a value derived from arbitrary user data, and never use byte-indexed &str slicing without a char_boundary guarantee.

Re-exports§

pub use extract_headings::extract_headings;
pub use extract_headings::HeadingInfo;
pub use page_kind::PageKind;
pub use resolved::Resolved;
pub use resolved::ResolvedOrigin;

Modules§

asset_paths
Pure URL/path transform helpers — no filesystem access, no env lookups. Used by moss-core’s render functions (see crate::render::*) and by upstream src-tauri call sites.
asset_snapshot
Pre-fetched asset metadata available to Stage 1 + Stage 2.
ast
Typed body AST.
content_graph
In-memory index of content files, headings, and block IDs.
contract
moss HTML/CSS contract surface.
csv_table
Pure CSV/TSV → HTML table renderer.
date
Publish-date resolution for moss content.
extract_headings
Pure extraction of a document’s headings (text + slug + level) for the editor’s [[Page#Heading]] autocomplete. Reuses parse() (which runs assign_heading_id_suffixes) so the returned slugs are byte-identical to the rendered <hN id="..."> attributes — the keystone invariant.
frontmatter
YAML frontmatter parsing with body preservation.
frontmatter_union
Normalization for union-typed frontmatter fields (children, series).
heading
Article heading rule — single source of truth for the auto-injected <h1 class="moss-article-title"> and the editor’s pinned heading element.
heading_anchor
Obsidian-compatible heading anchor generation.
home
Home file detection for the moss content model.
link_candidates
Link resolution candidate generation.
link_completions
Pure ranker for wikilink autocomplete completions.
media
Unified media reference resolution and display attributes.
page_kind
Classification of moss page/source-file kinds.
render
HTML synthesizers for moss-emitted markdown content.
resolve
Centralized link resolution — ALL wikilink handling (body AND frontmatter) happens here.
resolved
A value paired with its origin. Lets downstream consumers decide whether to honor the value as author intent (explicit) or override it with an inferred default (auto-detected).
schema
Content model types driven by the schema.
schema_fields
Builtin frontmatter field definitions.
shortcode_tokens
Tokenizer for shortcode opening, closing, and divider lines.
sort
Folder-listing sort: types and inference cascade.
validation
Schema-driven frontmatter validation.