lepture / mistune

A fast yet powerful Python Markdown parser with renderers and plugins.
http://mistune.lepture.com/
BSD 3-Clause "New" or "Revised" License
2.59k stars 251 forks source link

Fix premature (and incomplete) HTML-escaping of links #395

Open mentalisttraceur opened 5 days ago

mentalisttraceur commented 5 days ago

This fixes three bugs:

  1. links were being prematurely HTML-escaped (when being parsed into AST instead of waiting until rendering to HTML) ( #394 )
  2. image directive was double-escaping target links, and
  3. image directive wasn't escaping src links at all.

Same idea as the fix in #393 - move the HTML-escaping out of the parse and into the rendering.

Tests updated to catch all three bugs.

You can merge this and #393 in any order (no merge conflicts either way).

veenstrajelmer commented 5 days ago

Thanks for this PR. I locally checked out the branch to check its effect in my sphinx-build usecase. I just wanted to confirm that your PR indeed fixes the issue I encountered.

veenstrajelmer commented 5 days ago

And additionally, https://github.com/lepture/mistune/pull/393 fixes another issue I encountered only recently for the first time. Thanks for these very helpful contributions!