Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from docutils.utils import Reporter, SystemMessage, new_document
from docutils.utils.code_analyzer import Lexer, LexerError, NumberLines
from markdown_it import MarkdownIt
from markdown_it.common.utils import escapeHtml
from markdown_it.renderer import RendererProtocol
from markdown_it.token import Token
from markdown_it.tree import SyntaxTreeNode
Expand Down Expand Up @@ -954,7 +953,7 @@ def render_link_url(
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))
Expand Down
30 changes: 30 additions & 0 deletions tests/test_renderers/fixtures/docutil_syntax_elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -747,3 +747,33 @@ a = 1
<paragraph>
<reference refname="target">
.

URL with ampersand in query string
.
[link](https://example.com/search?q=foo&bar=baz)
.
<document source="notset">
<paragraph>
<reference refuri="https://example.com/search?q=foo&bar=baz">
link
.

URL with angle brackets (percent-encoded by normalizeLink, not HTML-escaped)
.
[link](https://example.com/path<with>brackets)
.
<document source="notset">
<paragraph>
<reference refuri="https://example.com/path%3Cwith%3Ebrackets">
link
.

URL with double quotes (percent-encoded by normalizeLink, not HTML-escaped)
.
[link](https://example.com/path"with"quotes)
.
<document source="notset">
<paragraph>
<reference refuri="https://example.com/path%22with%22quotes">
link
.
2 changes: 2 additions & 0 deletions tests/test_sphinx/sourcedirs/references/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

[nested *syntax*](https://example.com)

[query params](https://example.com?foo=bar&a=1)

[](title)

[plain text](title)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_sphinx/test_sphinx_builds/test_references.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ <h1>
</em>
</a>
</p>
<p>
<a class="reference external" href="https://example.com?foo=bar&amp;a=1">
query params
</a>
</p>
<p>
<a class="reference internal" href="#title">
<span class="std std-ref">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
nested
<emphasis>
syntax
<paragraph>
<reference refuri="https://example.com?foo=bar&a=1">
query params
<paragraph>
<reference internal="True" refid="title">
<inline classes="std std-ref">
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sphinx/test_sphinx_builds/test_references.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
nested
<emphasis>
syntax
<paragraph>
<reference refuri="https://example.com?foo=bar&a=1">
query params
<paragraph>
<pending_xref refdoc="index" refdomain="True" refexplicit="False" reftarget="title" reftype="myst">
<inline classes="xref myst">
Expand Down