:bug: FIX: Double encoded ampersands in query params by sumezulike · Pull Request #929 · executablebooks/MyST-Parser

This closes #760.

MyST already escapes the & in the query params, but docutils escapes them again when rendering HTML, leading to broken query params.

[Link](example.com?foo=1&bar=2)

becomes

<p><a href="example.com?foo=1&amp;amp;bar=2">Link</a></p>

instead of

<p><a href="example.com?foo=1&amp;bar=2">Link</a></p>

These changes to the docutils parser override the HTMLTranslator.encode function so already encoded ampersands are not encoded again.
Since the issue lies in the interaction with docutils, I think it makes sense to fix it here.
Also, simply removing the escapeHtml call in MyST makes the sphinx app doctree XML files invalid because the ampersands aren't escaped.