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 + <reference internal="True" refid="target2"> + <inline classes="std std-ref"> + link + <paragraph> + Content <target refid="target2"> <figure align="default" ids="id1 target2" names="target2"> <reference refuri="https://www.google.com"> @@ -140,7 +148,7 @@ <paragraph> Special substitution references: <paragraph> - 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 @@ <warning> <paragraph> xyz + <admonition classes="admonition-title-with-link-target2"> + <title> + Title with + <reference internal="True" refid="target2"> + <inline classes="std std-ref"> + link + <paragraph> + Content <target refid="target2"> <figure ids="id1 target2" names="target2"> <reference refuri="https://www.google.com"> @@ -140,7 +148,7 @@ <paragraph> Special substitution references: <paragraph> - 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 @@ <h1> </p> </div> </div> + <div class="admonition-title-with-link-target2 admonition"> + <p class="admonition-title"> + Title with + <a class="reference internal" href="#target2"> + <span class="std std-ref"> + link + </span> + </a> + </p> + <p> + Content + </p> + </div> <div class="figure align-default" id="id1"> <span id="target2"> </span> @@ -229,7 +242,7 @@ <h1> Special substitution references: </p> <p> - 53 words | 0 min read + 57 words | 0 min read </p> </div> </div> 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 @@ <warning> <paragraph> xyz + <admonition classes="admonition-title-with-link-target2"> + <title> + Title with + <pending_xref refdoc="content" refdomain="True" refexplicit="True" reftarget="target2" reftype="myst" refwarn="True"> + <inline classes="xref myst"> + link + <paragraph> + Content <target refid="target2"> <figure align="default" ids="id1 target2" names="target2"> <reference refuri="https://www.google.com"> @@ -141,7 +149,7 @@ <paragraph> Special substitution references: <paragraph> - 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 @@ <h1> </p> </div> </div> + <div class="admonition-title-with-link-target2 admonition"> + <p class="admonition-title"> + Title with + <a class="reference internal" href="#target2"> + <span class="std std-ref"> + link + </span> + </a> + </p> + <p> + Content + </p> + </div> <figure class="align-default" id="id1"> <span id="target2"> </span> @@ -231,7 +244,7 @@ <h1> Special substitution references: </p> <p> - 53 words | 0 min read + 57 words | 0 min read </p> </section> </div> 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 @@ <warning> <paragraph> xyz + <admonition classes="admonition-title-with-link-target2"> + <title> + Title with + <pending_xref refdoc="content" refdomain="True" refexplicit="True" reftarget="target2" reftype="myst" refwarn="True"> + <inline classes="xref myst"> + link + <paragraph> + Content <target refid="target2"> <figure ids="id1 target2" names="target2"> <reference refuri="https://www.google.com"> @@ -141,7 +149,7 @@ <paragraph> Special substitution references: <paragraph> - 53 + 57 words | 0 min read