Open torbsorb opened 2 years ago
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
I also encountered this bug when autosectionlabel_maxdepth
is not None
, and I write the 'including markdown file in rst file' syntax:
.. include:: ../../../CHANGELOG.md
:parser: myst_parser.sphinx_
When the parser is parsing this rst file, the error raises.
To avoid it, I set autosectionlabel_maxdepth=None
. Or remove the include
syntax.
Describe the bug
context When I use
sphinx.ext.autosectionlabel
andmyst_parser
for an rst project it triggers an exception:See also https://github.com/sphinx-doc/sphinx/issues/10902.
sphinx.ext.autosectionlabel
configuration:expectation I expected no exceptions to be raised.
bug
problem When
sphinx.ext.autosectionlabel
is trying to find node depth it looks forcur_node.parent == node.document
. However, withmyst_parser
the parent node of the document where this is included is not the parent. Instead the top-level parent is set toNone
. This is what triggers the exception. If the plan was to have None as the top-level parent, then https://github.com/sphinx-doc/sphinx/issues/10902 must be fixed. However, I believemyst_parser
should attempt to set parent node to the document where the markdown is included.Reproduce the bug
Enable sphinx.ext.autosectionlabel and use myst_parser
List your environment
Ubuntu 20.04 in WSL2 on Windows 11 Python 3.10.6 docutils 0.17.1 myst_parser 0.18.0