Skip to content

Commit 91b3424

Browse files
committed
chore: Compat with Sphinx>=9
1 parent 663202e commit 91b3424

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/sphinxnotes/data/render/markup.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from docutils.utils import new_document
1818
from sphinx.util.docutils import SphinxDirective, SphinxRole
1919
from sphinx.transforms import SphinxTransform
20+
from sphinx import version_info
2021

2122
from .render import Host
2223

@@ -40,11 +41,12 @@ def _render(self, text: str) -> list[Node]:
4041
if isinstance(self.host, SphinxDirective):
4142
return self.host.parse_text_to_nodes(text)
4243
elif isinstance(self.host, SphinxTransform):
43-
# TODO: sphinx>9
44-
# https://github.com/missinglinkelectronics/sphinxcontrib-globalsubs/pull/9/files
45-
settings = self.host.document.settings
4644
# TODO: dont create parser for every time
47-
parser = self.host.app.registry.create_source_parser(self.host.app, 'rst')
45+
if version_info[0] >= 9:
46+
parser = self.host.app.registry.create_source_parser('rst', env=self.host.env, config=self.host.config)
47+
else:
48+
parser = self.host.app.registry.create_source_parser(self.host.app, 'rst')
49+
settings = self.host.document.settings
4850
doc = new_document('<generated text>', settings=settings)
4951
parser.parse(text, doc)
5052
return doc.children

0 commit comments

Comments
 (0)