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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### 🐛 Bug Fixes

- Resolve named external hyperlinks inside `{eval-rst}` blocks, including links in tables.

## 5.2.0 - 2026-11-10

Heading anchors are now stable and documented:
Expand Down
3 changes: 3 additions & 0 deletions myst_parser/mdit_to_docutils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,9 @@ def render_restructuredtext(self, token: SyntaxTreeNode) -> None:
for node in newdoc:
if node["names"]:
self.document.note_explicit_target(node, node)
# Docutils resolves named hyperlinks using the host document's refnames.
for name, references in newdoc.refnames.items():
self.document.refnames.setdefault(name, []).extend(references)
self.current_node.extend(newdoc.children)

def render_directive(
Expand Down
20 changes: 20 additions & 0 deletions tests/test_docutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,26 @@ def test_parser():
)


def test_eval_rst_named_external_links() -> None:
"""Both table cells resolve their named reference to the external URL."""
source = """```{eval-rst}
====== ======
First Second
====== ======
guide_ guide_
====== ======

.. _guide: https://example.org/guide
```
"""
document = publish_doctree(source, parser=Parser())
table = next(document.findall(nodes.table))
assert [ref.get("refuri") for ref in table.findall(nodes.reference)] == [
"https://example.org/guide",
"https://example.org/guide",
]


def test_parsed_literal_preserves_line_edge_whitespace():
"""Line-edge whitespace survives inline parsing in parsed literals."""
source = "\n".join(
Expand Down
Loading