Expand description
§lima
LIMA Is Metadata Annotation — a small, predictable frontmatter parser. A deliberate, focused subset of YAML: the part frontmatter actually needs, with well-defined types, no surprises, and zero runtime dependencies.
use lima::{parse, ParseOptions};
let result = parse(
"title: Hello World\npublished: 2024-03-01\ndraft: false\n",
ParseOptions::default(),
).unwrap();parse_core implements Lima Core 1.2 in full (block/flow sequences
and mappings, dates, numbers, quoting, | literal block scalars).
parse implements References 2.1 on top of it. parse_references
remains as a deprecated alias with identical 2.1 semantics.
See https://limaformat.dev for the specification, and the
TypeScript implementation (@limaformat/lima on npm) for a second,
independently maintained reference.
§Conformance
Checked against the shared, language-neutral conformance corpus through Lima Core 1.2 and References 2.1 (including the additive 1.2/2.1 suites), plus the frozen References 1.0 corpus. The Core 1.0/1.1 and References 1.0 baselines remain count- and hash-pinned by their corpus manifests.
Re-exports§
pub use crate::core::parse_core;pub use crate::core::CoreOptions;pub use crate::errors::Diagnostic;pub use crate::references2::parse;pub use crate::references2::parse_references;Deprecated pub use crate::references2::ParseMode;pub use crate::references2::ParseOptions;pub use crate::references2::ReferencesOptions;Deprecated
Modules§
- block
- Core §7 block collections (sequences and mappings). Mirrors
js/src/block.ts, with the same performance-motivated ASCII fast paths deliberately dropped (seescalars.rs’s module doc) —trim_sliceandstrip_key_quotesare called uniformly instead of branching on whether a fast path applies. Generic overBuilder— seescalars.rs’s module doc. - core
- Public entry point — orchestrates
block/flow/scalarsinto a full document parse. Mirrorsjs/src/core.ts’s top-level scan (findkey:/key: valuelines at column 0; everything else — including a strict-mode non-key line — is silently skipped, per Core §10.1’s closed strict-error list) plus its|literal block-scalar merging.block::parse_block_rangeis used only for a barekey:’s nested content, exactly as in the TS source, not for the top level itself. - errors
- Structured internal diagnostics — mirrors
js/src/errors.ts. - flow
- Core §15.8 flow collections:
[...]sequences and{...}mappings. Mirrorsjs/src/flow.ts. Generic overBuilder— seescalars.rs’s module doc. - normalize
- Shared, domain-agnostic parsing primitives — mirrors
js/src/normalize.ts. - references2
- Lima References 2.1 resolver. The frozen 1.0 implementation remains in
references.rssolely for its conformance tests. - scalars
- Core scalar grammar — mirrors
js/src/scalars.ts: dates, numbers/type coercion, quoting/escaping, and the shared quoted-or-typed scalar parser. - value
- Lima Value Model — mirrors
js/src/value.ts. Unlike JS’s singlenumbertype, Rust genuinely distinguishesi64fromf64, so the int/float tagging carried here is not extra ceremony — it’s the representation a Rust port needs from the moment a scalar is recognised.