How johanneskaufmann/html-to-markdown works
html-to-markdown converts parsed HTML into Markdown through a configurable Go converter, with a library wrapper and a CLI path for input selection, optional plugins, and output. The core stages are parsing/filtering, plugin-driven rendering, and output formatting; shared collapse and escaping utilities support rendering. The README also describes custom tag renderers, CommonMark options, strikethrough, and tables. Edges reflect the supplied excerpts or explicit README usage; unsampled CLI I/O and converter internals are not expanded into guessed calls.
Main entry points: cmd_convert.go CLI command · base.go Base cleanup · commonmark.go CommonMark syntax · convert.go Go library API
Components 22
Entry points
- Go library API
convert.go - CLI command
cli/html2markdown/cmd/cmd_convert.go - CLI executable
cli/html2markdown/main.go
Conversion engine
- Converter runtime
converter/convert.go - Plugin registration
converter/register.go - Tag render registry
converter/register.go
Rendering plugins
- Base cleanup
plugin/base/base.go - HTML wrappers
plugin/base/renderers.go - CommonMark syntax
plugin/commonmark/commonmark.go - Code rendering
plugin/commonmark/render_code.go - Heading rendering
plugin/commonmark/render_heading.go - Strikethrough
plugin/strikethrough/strikethrough.go - Table plugin
plugin/table/table.go - Table collection
plugin/table/2_collect.go - Table formatting
plugin/table/3_render.go
Shared processing
- Whitespace collapse
collapse/collapse.go - DOM helpers
internal/domutils - Text helpers
internal/textutils - Markdown escaping
internal/escape
Other components
- Library caller
- CLI user
- Markdown output
Connections 30
- Library caller → Go library API: provides HTML
convert.go - Go library API → Converter runtime: constructs and converts
convert.go - CLI user → CLI executable: invokes
cli/html2markdown/main.go - CLI executable → CLI command: calls Run
cli/html2markdown/main.go - CLI command → Converter runtime: parses and converts
cli/html2markdown/cmd/cmd_convert.go - CLI command → Base cleanup: registers
cli/html2markdown/cmd/cmd_convert.go - CLI command → CommonMark syntax: registers
cli/html2markdown/cmd/cmd_convert.go - CLI command → Strikethrough: optionally registers
cli/html2markdown/cmd/cmd_convert.go - CLI command → Table plugin: optionally registers
cli/html2markdown/cmd/cmd_convert.go - Go library API → Base cleanup: registers
convert.go - Go library API → CommonMark syntax: registers
convert.go - Converter runtime → Plugin registration: uses
- Plugin registration → Tag render registry: configures
converter/register.go - Base cleanup → Whitespace collapse: collapses whitespace
plugin/base/base.go - Base cleanup → DOM helpers: merges text nodes
plugin/base/base.go - Base cleanup → Text helpers: trims output
plugin/base/base.go - Base cleanup → Markdown escaping: escapes content
- CommonMark syntax → DOM helpers: normalizes lists
plugin/commonmark/commonmark.go - CommonMark syntax → Markdown escaping: registers unescapers
plugin/commonmark/commonmark.go - CommonMark syntax → Code rendering: delegates code syntax
- CommonMark syntax → Heading rendering: delegates headings
- HTML wrappers → Tag render registry: provides renderers
plugin/base/renderers.go - Strikethrough → DOM helpers: normalizes elements
plugin/strikethrough/strikethrough.go - Strikethrough → Text helpers: wraps multiline text
plugin/strikethrough/strikethrough.go - Table plugin → Table collection: collects cell content
plugin/table/2_collect.go - Table plugin → Table formatting: renders table output
- Table collection → Text helpers: renders cell nodes
plugin/table/2_collect.go - Converter runtime → Markdown output: returns Markdown
- Go library API → Markdown output: returns Markdown
convert.go - CLI command → Markdown output: returns Markdown
cli/html2markdown/cmd/cmd_convert.go