Skip to content
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

code-block:: diff is not highlighted with this theme #1506

Closed
K20shores opened this issue Oct 11, 2023 · 6 comments
Closed

code-block:: diff is not highlighted with this theme #1506

K20shores opened this issue Oct 11, 2023 · 6 comments
Labels
kind: bug Something isn't working

Comments

@K20shores
Copy link

There appears to be an incompatibility between this theme and the code highlighting for code-block:: diffs.

conda create --name example
conda activate example
conda install pip 
conda install sphinx --channel conda-forge
mkdir test
cd test
sphinx-quickstart

In index.rst add this:

.. code-block:: diff

    #include <a.h>
  + #include <b.h>
  - #include <asdf.h>
    #include <c.h>

Make the docs: make html and view them.

The default alabaster theme renders this with color:

Screenshot 2023-10-11 at 3 38 20 PM

Now, install this theme

conda install pydata-sphinx-theme --channel conda-forge

and setup the conf.py to use this theme and remake the docs.

make html

Looking at the output, the diff is not appropriately color coded.

Screenshot 2023-10-11 at 3 40 19 PM
@12rambau 12rambau added the kind: bug Something isn't working label Oct 13, 2023
@12rambau
Copy link
Collaborator

12rambau commented Oct 19, 2023

To render code highighting, sphinx uses Pygment. I wasn't aware of this one but you are very right the diff lexer do exist and should be supported.

There are 2 options here:
1/ the color style used in the theme is not supporting the diff lexer
2/ some css override of the them are preventing the lexer to work

I am swamped with other issues so could you simply try on your example to change the pygment style in the option ?

html_theme_options = {
   #...
   "pygment_light_style": "tango",
   "pygment_dark_style": "monokai"
}

and let me know if it works ?

@K20shores
Copy link
Author

@12rambau that works for me!

@K20shores
Copy link
Author

For what it's worth I know that this used to work with an older version of this theme. Unfortunately I don't know which. Sometime last year I started using this theme and had that installed in a conda environment. Last week when I upgraded I noticed this issue. So, something in the past year in either sphinx or this caused the highlighting to disappear. I know that's vague but it's the best I can offer.

@12rambau
Copy link
Collaborator

we recently added lots of things in the theme related to accessibility including specific a11y compatible pygment styles. I'll open an issue on there end and tag you there.

@drammock
Copy link
Collaborator

I opened Quansight-Labs/accessible-pygments#31 about this.

@drammock
Copy link
Collaborator

closing since it's ultimately an upstream feature request, nothing we can do in this repo to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants