Skip to content

Add Markdown → HTML conversion (closes #11)#49

Open
DandyLyons wants to merge 1 commit into
mainfrom
feat-md2html
Open

Add Markdown → HTML conversion (closes #11)#49
DandyLyons wants to merge 1 commit into
mainfrom
feat-md2html

Conversation

@DandyLyons

Copy link
Copy Markdown
Owner

Summary

  • Adds MarkdownDocument.toHTML(options:) backed directly by the cmark-gfm renderer — no double-parsing, no AST traversal
  • Introduces MarkdownExtensionOptions (OptionSet with Int64 rawValue) as a public API mirror of CMExtensionOption, keeping cmark as an implementation detail
  • Adds HTMLOptions (ConversionOptions-conforming) with includeFrontmatter, wrapInDocument, hardBreaks, allowUnsafeHTML, smartPunctuation, and per-extension toggles
  • Adds md-utils convert to-html CLI command with --wrap-document, --include-frontmatter, --hard-breaks, --allow-unsafe-html, --smart-punctuation, and --no-X flags for each GFM extension (tables, autolinks, strikethrough, tagfilters, tasklist)
  • 16 library-level tests + CLI integration/parsing tests (806 total, all passing)

Supported features (default options)

Feature Flag to disable
CommonMark block/inline elements always on
GFM tables --no-tables
URL autolinks --no-autolinks
Strikethrough --no-strikethrough
Tag filtering --no-tagfilters
Task list checkboxes --no-tasklist
Footnotes always on

Test plan

  • swift build — clean, no errors
  • swift test — 806 tests, 0 failures
  • echo "# Hello\n\n**World**" | swift run md-utils convert to-html — correct HTML output
  • --wrap-document produces <!DOCTYPE html> skeleton
  • --no-tables passes table markdown through as plain paragraphs
  • GFM strikethrough → <del>, task lists → <input type="checkbox">

🤖 Generated with Claude Code

Introduces `MarkdownDocument.toHTML(options:)` backed by cmark-gfm,
a new `HTMLOptions` type with per-feature GFM extension toggles via
`MarkdownExtensionOptions`, and a `md-utils convert to-html` CLI command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant