Repository navigation
0.3.0: html2markdown (HTML to Markdown) - #1
Merged
Merged
Conversation
New html2markdown(html, *, base_url=None) (src/markdown.rs) walks the DOM html2text parses and writes CommonMark with GitHub's tables and strikethrough: inline links and images with absolute URLs, pipe tables, fenced code tagged with its language, `_em_` and `**strong**`, `-` bullets, and escapes only where Markdown would otherwise misread the text. Each paragraph with formatting is checked against the flanking rules and read back with pulldown-cmark; if it doesn't parse as intended it is rewritten with `*`, then without the formatting, so no stray delimiters reach the output. Checked by rendering the Markdown back with markdown-it and comparing words, links and images with the page (tests/markdown_check.py): 25 real pages, 172 Hugo pages and 50,000 random documents round-trip clean. markdownlint passes on 195 of 197 converted pages; the other two have lists the source numbers from 2, and one bold-italic construct that can only be written with both `_` and `*`. Hostile nesting and table spans stay linear. html2text() output is byte-identical to 0.2.0 (275 page/option hashes). Also: pin the fork commit that exports NodeData and resolve_url; tests and README; html2markdown in the PGO training and the benchmark; the round-trip tests' dependencies in CI. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WobasfsvfjJy3c6nkovhov
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
html2markdown(html, *, base_url=None): HTML to CommonMark with GitHub's tables and strikethrough.[text](url)/, made absolute withbase_url#headings,-bullets,_em_,**strong**,~~strike~~Checks
tests/markdown_check.py, run in CI bytests/test_markdown.py.**_x_**-style signatures) with no single-style form.html2text()output byte-identical to 0.2.0 (275 page/option hashes).Merging and tagging
v0.3.0publishes to PyPI.🤖 Generated with Claude Code
https://claude.ai/code/session_01WobasfsvfjJy3c6nkovhov