Skip to content

Conversation

drammock
Copy link
Member

@drammock drammock commented Jun 12, 2025

WIP. Makes it so that the content of .. include:: directives (handled by docutils) with the :code: option gets lexed in the same way that Sphinx-handled .. code-block:: directives are lexed (using short classnames like "ow" instead of long ones like "operator word"). Relies on the presence of a docutils.conf file ; so far I've got it working for tox run -e docs-live but haven't looked into the deployed docs / CIs to make sure it gets picked up there.

xrefs:

@drammock
Copy link
Member Author

it worked on the CI doc build too: https://pydata-sphinx-theme--2222.org.readthedocs.build/en/2222/user_guide/extending.html

note how the CSS samples are now syntax-highlighted, as are the rST samples in the tabbed boxes. The markdown samples (the other half of the tabbed boxes) aren't highlighted for (I think) two reasons:

  1. they're in a .. code-block:: not an .. include:: so their HTML nodes (and classes) are different
  2. because they're bits of MyST-specific markup, they're not actually lexed very well as markdown, and AFAICT there isn't a myst-specific lexer built into Pygments (though I think one exists, based on a quick scan of the source code of e.g. this page)

@drammock drammock marked this pull request as ready for review August 25, 2025 20:01
@gabalafou
Copy link
Collaborator

Is this PR ready now? Asking because it still says WIP in the description.

It looks good to go from my view

@drammock
Copy link
Member Author

Is this PR ready now? Asking because it still says WIP in the description.

It looks good to go from my view

yep, ready!

@drammock drammock merged commit 4952473 into pydata:main Aug 26, 2025
31 checks passed
@drammock drammock deleted the fix-include-highlight branch August 26, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants