Summary
Implement a new Layer 3 Swift package: md-to-html-swift for direct Markdown → HTML conversion.
This is the reverse pair of the in-flight html-to-md-swift work and is already promoted to P0 by the conversion matrix rules.
Why
html-to-md-swift makes the reverse path architecturally straightforward.
- Direct Markdown → HTML avoids routing through other hub formats.
- The CLI should expose a first-class Markdown → HTML command instead of forcing downstream tools to shell out to unrelated renderers.
Proposed package shape
- New package:
packages/md-to-html-swift
- Layer: Layer 3 (converter/renderer)
- Product:
MDToHTMLSwift
- Platform: Swift 5.9+, macOS 14+
Dependencies
Layer 2
doc-converter-swift
- use
DocumentConverter
- use
StreamingOutput
- use shared
ConversionOptions / ConversionError
Layer 1 / parsing
swift-markdown (Apple) for Markdown AST parsing
- gives a structured parser instead of regex-based rendering
- keeps the converter target-aware and easier to test
If swift-markdown proves too heavy for the initial cut, start with a minimal internal parser for the supported subset and keep the package boundary compatible with a future parser swap.
Implementation sketch
- Add
MarkdownToHTMLConverter that conforms to DocumentConverter
- Parse Markdown input into an AST / block sequence
- Emit HTML through
StreamingOutput incrementally
- Preserve streaming-friendly output APIs (
convert(input:output:), convertToString(...))
- Support core Markdown constructs first:
- headings
- paragraphs
- emphasis / strong / code spans
- fenced code blocks
- blockquotes
- ordered / unordered lists
- links / images
- horizontal rules
CLI integration
Add a new macdoc md to-html command (or equivalent Markdown command group consistent with existing CLI conventions).
Test strategy
- Unit tests for block-level rendering
- Unit tests for inline rendering and escaping
- Fixture tests for nested lists, blockquotes, code fences, links, and images
- CLI smoke test that verifies output file creation and representative HTML fragments
- Aim for 80%+ coverage in the new package
Acceptance criteria
swift test passes from repo root
- new package builds independently
- CLI exposes Markdown → HTML conversion
CONVERSIONS.md is updated from planned → active/implemented as work progresses
Summary
Implement a new Layer 3 Swift package:
md-to-html-swiftfor direct Markdown → HTML conversion.This is the reverse pair of the in-flight
html-to-md-swiftwork and is already promoted to P0 by the conversion matrix rules.Why
html-to-md-swiftmakes the reverse path architecturally straightforward.Proposed package shape
packages/md-to-html-swiftMDToHTMLSwiftDependencies
Layer 2
doc-converter-swiftDocumentConverterStreamingOutputConversionOptions/ConversionErrorLayer 1 / parsing
swift-markdown(Apple) for Markdown AST parsingIf
swift-markdownproves too heavy for the initial cut, start with a minimal internal parser for the supported subset and keep the package boundary compatible with a future parser swap.Implementation sketch
MarkdownToHTMLConverterthat conforms toDocumentConverterStreamingOutputincrementallyconvert(input:output:),convertToString(...))CLI integration
Add a new
macdoc md to-htmlcommand (or equivalent Markdown command group consistent with existing CLI conventions).Test strategy
Acceptance criteria
swift testpasses from repo rootCONVERSIONS.mdis updated fromplanned→active/implementedas work progresses