strum
Strum
STRuctured Markdown - Convert between structured data and Markdown documents.
What is Strum?
Strum provides bidirectional conversion between structured data (JSON/Crystal) and Markdown documents with sections, metadata, and formatted content.
Perfect for:
- Document generation from structured data
- Parsing user-edited Markdown back to structure
- Template rendering with dynamic content
- Building documentation systems
Features
- ✅ Bidirectional: JSON ↔ Markdown
- ✅ Sections: Documents with headings, IDs, and metadata
- ✅ Formats: Checklists, tables, code blocks
- ✅ Metadata: YAML or JSON frontmatter per section
- ✅ Fluent API: Builder pattern for constructing documents
Installation
Add to your shard.yml:
dependencies:
strum:
path: ../strum # or github: you/strum
Usage
Building Documents
require "strum"
# Build a structured document
doc = Strum::Builder.new
.section("auth-todos", "Authentication TODOs", metadata: {"kind" => JSON::Any.new("todo")}) do |b|
b.text("Implementation tasks:")
b.checklist([
{text: "Add JWT middleware", done: false},
{text: "Write tests", done: true},
{text: "Add documentation", done: false}
])
end
.to_markdown
puts doc
Output:
## [auth-todos] Authentication TODOs
---
kind: "todo"
---
Implementation tasks:
- [ ] Add JWT middleware
- [x] Write tests
- [ ] Add documentation
Parsing Documents (TODO)
markdown = File.read("todo.md")
doc = Strum::Parser.parse(markdown)
doc.sections.each do |section|
puts "Section: #{section.title}"
puts "ID: #{section.id}"
end
Formatting Utilities
# Format checklist
checklist = Strum::Formatter.checklist([
{text: "Done", done: true},
{text: "Pending", done: false}
])
# => "- [x] Done\n- [ ] Pending"
# Format code block
code = Strum::Formatter.code_block("puts 'hello'", "crystal")
# => "```crystal\nputs 'hello'\n```"
Roadmap
- Basic document structure (Document, Section)
- Builder API for constructing documents
- Checklist formatting
- YAML metadata rendering
- Markdown parser (Markdown → Structure)
- Table formatting
- Template system
- More content types (images, links, etc.)
Development
# Run tests
crystal spec
# Build
shards build
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-feature) - Commit your changes (
git commit -am 'Add feature') - Push to the branch (
git push origin my-feature) - Create a Pull Request
License
MIT License - see LICENSE file
Repository
strum
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- 12 days ago
- March 22, 2026
License
Links
Synced at
Sun, 22 Mar 2026 01:52:03 GMT
Languages