@rashidazarang/import-markdown
v0.1.1
Published
Markdown manuscript importer for the subframe-v1 composition format. Reads a chapter .md (YAML frontmatter + minimal Markdown subset) and emits a schema-validated composition JSON; walks a manuscript tree and emits a subframe-book-v1 manifest.
Maintainers
Readme
@rashidazarang/import-markdown
Markdown manuscript importer for the
subframe-v1 composition format. Reads a
chapter .md (YAML frontmatter + a minimal Markdown subset: paragraphs,
##/###/#### headings, > epigraphs, --- section breaks, and
inline **bold** / *italic* / _italic_) and emits a
schema-validated composition JSON. Walks a manuscript tree and emits a
subframe-book-v1 manifest.
Every emitted composition is validated against the
canonical schema via
@rashidazarang/subframe-core's validateComposition. Validation failures
throw SubframeValidationError — they are never warnings.
Install
pnpm add @rashidazarang/import-markdownCLI
# single chapter
resonant-import-md build-chapter ./chapter.md ./out/chapter.json
# whole manuscript tree
resonant-import-md build-book ./manuscript ./outExit codes:
0— success1— invalid arguments2— schema validation failure
Progress is logged to stderr — one line per chapter — plus a final summary with chapter count, total block count, and a section breakdown.
Programmatic
import { buildComposition, buildBook } from '@rashidazarang/import-markdown';
const doc = buildComposition('./chapter.md');
// doc is a CompositionDocument from @rashidazarang/subframe-core,
// already validated against subframe-v1.schema.json.
const { manifest, chapters } = buildBook({
root: './manuscript',
outDir: './out'
});
// manifest is a BookManifest; chapters is { id, outPath }[]
// so callers can post-process without re-reading the disk.Frontmatter
The minimal frontmatter shape (every key optional except title):
---
title: Sobre Despertar
slug: sobre-despertar # falls back to filename stem
section: parte-1-despertar # used to group sections in book.json
part_number: 1 # parte-N
part_title: "..." # human label override for the section
chapter_number: 1 # null/omitted for intro chapters
order: 1 # reading order within the section
language: es # BCP 47; defaults to "es"
book: manual-sobre-el-despertar
status: draft
---Output format
Both outputs conform to the canonical schemas. See
spec/subframe-v1.md for normative details
and
spec/subframe-v1.schema.json /
spec/subframe-book-v1.schema.json
for the validators.
License
Apache-2.0 — see LICENSE at the repository root.
