[ENH/FIX] Support headings in nested parse #1102
Open
+88
−29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes using Markdown headings in Sphinx objects, like the
object,describe,py:datadirectives, etc.; which fixes #1050.In summary, this should now work:
This works by adding the heading to the temp root parent instead of at the end of the previous section from the main document.
I've also added a change to the "heading to rubric" conversion in nested headings, whose levels now will be offset by the current heading level. So this:
will generate an
h3rubric inside the blockquote (offset by the "Sub-title" heading).This makes it consistent with the way it works with Markdown headings inside objects (which is consistent with RST's headings inside objects).
Tell me if you think this change is appropriate, if not I can always remove the commit.
I've also used the
heading-leveloption from Sphinx'rubricdirective, so that Sphinx generate appropriately leveled headers from those rubrics.Edit: for the offsetting of nested headers, I had to change a part of the documentation, because an example generated a level 4 headers, whose id wasn't generated due to a
myst_heading_anchorsvalue too low.