Strum
Strum - Structured Markdown
Convert between JSON and Markdown documents.
Features
- Bidirectional: JSON ↔ Markdown
- Sections: Documents with headings, metadata, and content
- Configurable formats: JSON or YAML, compact or multiline
- Metadata: Configurable frontmatter per section
Usage
# JSON structure (simplified for Copious)
sections = [
{
"id" => "auth-design",
"title" => "Auth Design",
"level" => 2,
"metadata" => {"kind" => "design", "status" => "proposed"},
"content" => "Authentication system design."
}
]
# Convert to markdown with options
options = Strum::Options.new(
metadata_format: :yaml,
metadata_style: :multiline
)
markdown = Strum.to_markdown(sections, options)
# Parse markdown back to JSON
parsed = Strum.parse(markdown_string)
Constants
VERSION = "0.1.0"
Instance methods
Parse Markdown string to JSON sections.
Parses structured markdown with headings, metadata, and content. Supports 4 metadata formats:
- Compact JSON: {"kind": "design"}
- Compact YAML: {kind: design}
- Multiline JSON with delimiters: --- {...} ---
- Multiline YAML with delimiters: --- key: value ---
Returns
Array of section hashes with:
- id: Section identifier from [brackets]
- title: Section title
- level: Heading level (1-6)
- metadata: Hash of metadata (optional)
- content: Text content (optional)
Convert JSON sections to Markdown string.
Parameters
- sections: Array of section hashes/namedtuples
- options: Rendering options (optional)
Section structure
- id: Section identifier (required)
- title: Section title (required)
- level: Heading level (default: 2)
- metadata: Hash of metadata key-value pairs (optional)
- content: Text content (optional)