diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py
index 4c407de1..7d1a8af9 100644
--- a/myst_parser/mdit_to_docutils/base.py
+++ b/myst_parser/mdit_to_docutils/base.py
@@ -1098,7 +1098,7 @@ def render_inventory_link(self, token: SyntaxTreeNode) -> None:
elif match.text:
ref_node.append(nodes.Text(match.text))
else:
- ref_node.append(nodes.Text(match.name))
+ ref_node.append(nodes.literal(match.name, match.name))
def get_inventory_matches(
self,
diff --git a/myst_parser/mdit_to_docutils/sphinx_.py b/myst_parser/mdit_to_docutils/sphinx_.py
index 4e7aee1d..36497194 100644
--- a/myst_parser/mdit_to_docutils/sphinx_.py
+++ b/myst_parser/mdit_to_docutils/sphinx_.py
@@ -80,29 +80,31 @@ def render_internal_link(self, token: SyntaxTreeNode) -> None:
refdomain="doc", reftarget=docname, reftargetid=path_id, **kwargs
)
classes = ["xref", "myst"]
- text = ""
else:
wrap_node = addnodes.download_reference(
refdomain=None, reftarget=path_dest, **kwargs
)
classes = ["xref", "download", "myst"]
- text = destination if not token.children else ""
else:
wrap_node = addnodes.pending_xref(
refdomain=None, reftarget=destination, **kwargs
)
classes = ["xref", "myst"]
- text = ""
self.add_line_and_source_path(wrap_node, token)
self.copy_attributes(token, wrap_node, ("class", "id", "title"))
self.current_node.append(wrap_node)
- inner_node = nodes.inline("", text, classes=classes)
- wrap_node.append(inner_node)
if explicit:
+ inner_node = nodes.inline("", "", classes=classes)
with self.current_node_context(inner_node):
self.render_children(token)
+ elif isinstance(wrap_node, addnodes.download_reference):
+ inner_node = nodes.literal(path_dest, path_dest, classes=classes)
+ else:
+ inner_node = nodes.inline("", "", classes=classes)
+
+ wrap_node.append(inner_node)
def get_inventory_matches(
self,
diff --git a/myst_parser/sphinx_ext/myst_refs.py b/myst_parser/sphinx_ext/myst_refs.py
index e00afc4d..8a4dc202 100644
--- a/myst_parser/sphinx_ext/myst_refs.py
+++ b/myst_parser/sphinx_ext/myst_refs.py
@@ -392,7 +392,7 @@ def _resolve_myst_ref_intersphinx(
)
else:
newnode.append(
- contnode.__class__(match.name, match.name, classes=["iref", "myst"])
+ nodes.literal(match.name, match.name, classes=["iref", "myst"])
)
return newnode
diff --git a/tests/test_renderers/fixtures/sphinx_link_resolution.md b/tests/test_renderers/fixtures/sphinx_link_resolution.md
index 85120769..d8616b38 100644
--- a/tests/test_renderers/fixtures/sphinx_link_resolution.md
+++ b/tests/test_renderers/fixtures/sphinx_link_resolution.md
@@ -199,11 +199,12 @@ c | d
-
- subfolder/file_link2.txt
-
+
+
+ subfolder/file_link2.txt
+
+
@@ -225,9 +227,11 @@
Known no title
-
- paragraph-target
-
+
+
+ paragraph-target
+
+
@@ -251,9 +255,11 @@
Ambiguous
-
- duplicate
-
+
+
+ duplicate
+
+