-
Notifications
You must be signed in to change notification settings - Fork 198
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
Unable to link with multiple query params #760
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
Reported also here: https://bugzilla.mozilla.org/show_bug.cgi?id=1828390 |
Heya, yep this is consistent with the CommonMark spec:
and also I believe with the HTML spec: https://stackoverflow.com/a/3705601/5033292 are you sure it is actually breaking the link, it doesn't appear to break for me in Firefox? |
What you said isn't quite correct; it turns it into |
@chrisjsewell yeah, the backslash escapes were for GitHub rendering to make a link that matches when you click it (if you look at the resulting href on GitHub it is accurate) Although testing on my phone just now it works as I would want it to, but that’s with the YouTube app handling it, not a browser |
I am having the exact same issue. For https://example.com?first=a&second=b, the api service I am using complains that the second parameter is Update: I ended up manually using sed to find and remove the |
Same here. Markdown-it-py 3.0.0 generates the correct url with $ markdown-it <(echo "[example](https://example.com?first=a&second=b)")
<p><a href="https://example.com?first=a&second=b">example</a></p> whereas myst-parser 2.0.0 yields a broken $ myst-docutils-demo <(echo "[example](https://example.com?first=a&second=b)")
<p><a class="reference external" href="https://example.com?first=a&amp;second=b">example</a></p> |
A potential solution would be to adjust the MyST-Parser code to prevent the initial escaping of the URL, allowing docutils or the final HTML writer to handle the necessary escaping. This could involve simply removing or modifying the call to escapeHtml in the MyST-Parser's conversion process. diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py
index 4a02459..cee67c9 100644
--- a/myst_parser/mdit_to_docutils/base.py
+++ b/myst_parser/mdit_to_docutils/base.py
@@ -996,7 +996,7 @@ class DocutilsRenderer(RendererProtocol):
if "classes" in conversion:
ref_node["classes"].extend(conversion["classes"])
- ref_node["refuri"] = escapeHtml(uri)
+ ref_node["refuri"] = uri
if implicit_text is not None:
with self.current_node_context(ref_node, append=True):
self.current_node.append(nodes.Text(implicit_text)) Additional Information: The issue seems to stem from both the MyST-Parser and docutils/html writers, where the URL is being escaped more than once.
|
Workaround using bit.ly because cannot make link URL with "&" because below problem executablebooks/MyST-Parser#760
I also encountered this issue with $ echo '[example](https://example.com?param1=value1¶m2=value2)' | myst-docutils-demo
<p><a class="reference external" href="https://example.com?param1=value1&amp;param2=value2">example</a></p> Ended up working around it using explicit HTML, e.g.; $ echo '<a href="https://example.com?param1=value1¶m2=value2">example</a>' | myst-docutils-demo
<p><a href="https://example.com?param1=value1¶m2=value2">example</a></p> Not elegant, but might get you out of a pinch! |
Describe the bug
context
I am trying to make a link containing query params such as
https://example.com?first=a&second=b
expectation
I expected that the rendered link would contain all of the query params.
bug
But instead the
&
becomes encoded as&
and breaks the link. I thought I'd be able to escape the&
or that it would work natively, but neither seem to be true.Reproduce the bug
and
Renders:
List your environment
Using MyST-Parser: 1.0.0
The text was updated successfully, but these errors were encountered: