Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace strip_html with markdown_excerpt #1406

Merged
merged 6 commits into from
May 15, 2024

Conversation

charmander
Copy link
Contributor

markdown_excerpt is more complete (renders Markdown, normalizes whitespace), correct (produces plain text), and robust (uses lxml.html, which doesn’t crash on the same malformed input that html.parser does).

Even when I originally wrote this in [2013-09-25 :/Replaced BBCode with Markdown], the output of `strip_html` was used escaped, so it wasn’t correct then. Making the parser class local to the call with a `text_parts` class variable was also questionable style.

As of Python 3.5, `HTMLParser` never calls `handle_entityref` or `handle_charref` by default.
@charmander charmander merged commit 4d0aa2c into Weasyl:main May 15, 2024
4 checks passed
@charmander charmander deleted the strip-html-refactor branch May 15, 2024 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant