Skip to main content

Module mdprism

Module mdprism 

Source
Expand description

§mdprism — markdown ⇄ data, via a template

One compact schema (a textual DSL) defines a bidirectional mapping between a markdown document and a typed data object. From it you can validate, extract (parse → data), render (data → markdown), scaffold, and edit in-place.

See docs/structure-dsl-spec.md for the language and docs/mdprism-reference.md for a worked example.

§Status

Implemented: schema parser (parse_schema), Schema data model, scaffold (starter document), validate / extract (body conformance), render (data → markdown), and in-place edit. The jq-based query selector was dropped once corpus stats moved to SQL.

Structs§

FieldSchema
One typed frontmatter key.
Head
The shared annotation head of every node: alias, cardinality, description.
Problem
One way a document failed to conform, addressed by the breadcrumb path (alias chain) of the schema node that was unmet.
Schema
A parsed schema: per-schema options, the frontmatter field schemas, and the body node tree.
SchemaError
A failure while parsing the DSL schema source. Carries a 1-based line/column.
SchemaOpts
The %-directive options. Defaults match the spec: strict ordering, strict matching, closed frontmatter.

Enums§

Card
Cardinality. On a list it bounds item count; on a heading/prose it is presence. Required is the bare default.
EditError
A failure while editing a document in-place via [Schema::edit].
FieldType
A frontmatter value type. Regex keeps the pattern source so the type is PartialEq/Clone; compile it on demand.
ListStyle
Match
A label: a literal the text must start with, or a regex (pattern source) the text must match. A bare heading title is a Literal.
Node
A body node: a heading (with children), a list (with a per-item child schema), or a required paragraph.
RenderError
A failure while rendering markdown from data via [Schema::render].

Functions§

parse_schema
Parse a schema from DSL source.