-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Problem
I am finding that code blocks render differently based on where in a document they are. If a code block is at the root scope, it renders just fine. But anything rendered nested inside of a function/class has some of the keywords italicized.
In the following example, the def and pass keywords are not italicized in the first code block and are italicized in the second code block. The import keyword is always not italicized.
I believe this code is the culprit. This was added in #1123, where it seems like maybe it was added to work around another bug?
Reproducible Project
The following rst code replicates the issue, I have it saved as index.rst
.. code-block:: python
import bar
def foo():
"""This is a simple function."""
pass
.. function:: foo(arg1, arg2, ...)
Description of the function.
.. code-block:: python
import bar
def foo():
"""This is a simple function."""
passAssociated conf.py
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]I have both index.rst and conf.py in a folder, where I run sphinx-build -M html . build.
Error Logs/Results
Expected Results
I would expect consistent behavior, where I think none of the keywords should be italicized
Environment Info
- Python Version: 3.13.5
- Sphinx Version: 7.2.6
- RTD Theme Version: 3.0.2
