Skip to content

enable syntax highlighting in include directive #2222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

drammock
Copy link
Collaborator

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
Collaborator 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)

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.

1 participant