From 9362e449c74882d38868f60fd9850922f65c7993 Mon Sep 17 00:00:00 2001
From: Chris Sewell
Date: Thu, 16 Dec 2021 23:16:48 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Use=20correct=20rende?=
=?UTF-8?q?rer=20for=20`state.inline=5Ftext`=20(#466)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Previously `state.inline_text()` (used by some directives)
always parsed text with the `DocutilsRenderer`.
Now it will correctly use the `SphinxRenderer`,
when parsing with sphinx,
allowing for cross-document references to be handled.
---
myst_parser/mocking.py | 4 +---
tests/test_sphinx/sourcedirs/basic/content.md | 4 ++++
tests/test_sphinx/test_sphinx_builds.py | 2 +-
.../test_basic.resolved.sphinx3.xml | 10 +++++++++-
.../test_basic.resolved.sphinx4.xml | 10 +++++++++-
.../test_sphinx_builds/test_basic.sphinx3.html | 15 ++++++++++++++-
.../test_sphinx_builds/test_basic.sphinx3.xml | 10 +++++++++-
.../test_sphinx_builds/test_basic.sphinx4.html | 15 ++++++++++++++-
.../test_sphinx_builds/test_basic.sphinx4.xml | 10 +++++++++-
9 files changed, 70 insertions(+), 10 deletions(-)
diff --git a/myst_parser/mocking.py b/myst_parser/mocking.py
index 7812de94..382596e2 100644
--- a/myst_parser/mocking.py
+++ b/myst_parser/mocking.py
@@ -181,9 +181,7 @@ def inline_text(
# so that the nested parse does not effect the current renderer,
# but we use the same env, so that link references, etc
# are added to the global parse.
- from myst_parser.docutils_renderer import DocutilsRenderer
-
- nested_renderer = DocutilsRenderer(self._renderer.md)
+ nested_renderer = self._renderer.__class__(self._renderer.md)
options = {k: v for k, v in self._renderer.config.items()}
options.update(
{
diff --git a/tests/test_sphinx/sourcedirs/basic/content.md b/tests/test_sphinx/sourcedirs/basic/content.md
index 76499e31..e3872f34 100644
--- a/tests/test_sphinx/sourcedirs/basic/content.md
+++ b/tests/test_sphinx/sourcedirs/basic/content.md
@@ -34,6 +34,10 @@ abcd *abc* [google](https://www.google.com)
````
+```{admonition} Title with [link](target2)
+Content
+```
+
(target2)=
```{figure} example.jpg
diff --git a/tests/test_sphinx/test_sphinx_builds.py b/tests/test_sphinx/test_sphinx_builds.py
index 08d17055..1c6aa287 100644
--- a/tests/test_sphinx/test_sphinx_builds.py
+++ b/tests/test_sphinx/test_sphinx_builds.py
@@ -67,7 +67,7 @@ def test_basic(
"date": "2/12/1985",
"copyright": "MIT",
"other": "Something else",
- "wordcount": {"minutes": 0, "words": 53},
+ "wordcount": {"minutes": 0, "words": 57},
}
diff --git a/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx3.xml b/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx3.xml
index e04808ef..762dc6bd 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx3.xml
+++ b/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx3.xml
@@ -32,6 +32,14 @@
xyz
+
+
+ Title with
+
+
+ link
+
+ Content
@@ -140,7 +148,7 @@
Special substitution references:
- 53
+ 57
words |
0
min read
diff --git a/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx4.xml b/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx4.xml
index 50d08c88..ed086997 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx4.xml
+++ b/tests/test_sphinx/test_sphinx_builds/test_basic.resolved.sphinx4.xml
@@ -32,6 +32,14 @@
xyz
+
+
+ Title with
+
+
+ link
+
+ Content
@@ -140,7 +148,7 @@
Special substitution references:
- 53
+ 57
words |
0
min read
diff --git a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.html b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.html
index 75f6db91..36dd8c84 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.html
+++ b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.html
@@ -55,6 +55,19 @@
+
diff --git a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.xml b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.xml
index b77b95e3..775a420e 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.xml
+++ b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx3.xml
@@ -32,6 +32,14 @@
xyz
+
+
+ Title with
+
+
+ link
+
+ Content
@@ -141,7 +149,7 @@
Special substitution references:
- 53
+ 57
words |
0
min read
diff --git a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.html b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.html
index 555bc855..743f7a19 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.html
+++ b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.html
@@ -55,6 +55,19 @@
+
@@ -231,7 +244,7 @@
Special substitution references:
- 53 words | 0 min read
+ 57 words | 0 min read
diff --git a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.xml b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.xml
index ee7c75a7..c793d318 100644
--- a/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.xml
+++ b/tests/test_sphinx/test_sphinx_builds/test_basic.sphinx4.xml
@@ -32,6 +32,14 @@
xyz
+
+
+ Title with
+
+
+ link
+
+ Content
@@ -141,7 +149,7 @@
Special substitution references:
- 53
+ 57
words |
0
min read