Skip to content

DOC Use different themes for code syntax highlighting - #35059

Closed
DeaMariaLeon wants to merge 6 commits into
scikit-learn:mainfrom
DeaMariaLeon:theme
Closed

DeaMariaLeon wants to merge 6 commits into
scikit-learn:mainfrom
DeaMariaLeon:theme

Conversation

@DeaMariaLeon

@DeaMariaLeon DeaMariaLeon commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Reference Issues/PRs

Addresses a conversation that started here: #34376 (comment)

What does this implement/fix? Explain your changes.

Introduce yourself

AI usage disclosure

I used AI assistance for:

Any other comments?

@DeaMariaLeon
DeaMariaLeon marked this pull request as ready for review October 1, 2026 11:32
@DeaMariaLeon DeaMariaLeon added this to Labs Oct 1, 2026
@DeaMariaLeon DeaMariaLeon changed the title MAINT: Change code syntax highlight theme per popular opinion DOC Use GitHub-style high-contrast themes for code syntax highlighting Oct 1, 2026
@betatim

betatim commented Oct 1, 2026

Copy link
Copy Markdown
Member

I looked at https://output.circle-artifacts.com/output/job/8a136c6d-99bb-4213-88a2-0a1299751a42/artifacts/0/doc/auto_examples/release_highlights/plot_release_highlights_1_4_0.html (randomly picked an example page) to see the new highlighter in action. For me it looks like this:

Screenshot 2026-10-01 at 15 28 42

This looks different from what I was expecting to see based on https://quansight-labs.github.io/accessible-pygments/ There is a lot of purple text which feels hard to read/scan because everything is purple. I was somehow expecting more different colours for the different part of a line :-/

Below is a screenshot of what is currently on the 1.10dev docs build

Screenshot 2026-10-01 at 15 31 57

Here what is purple with the new theme is black. So maybe everything is as it should be with the new theme? If that is the case, then I find it harder to read than what we have.

Christian can you take a look as well and maybe explain what it is that you don't like/find hard to read/parse?

@DeaMariaLeon

DeaMariaLeon commented Oct 1, 2026 •

Copy link
Copy Markdown
Member Author

Everything that is "generic" (every span class="n") is purple. I think this is normal.
Please see all classes called "n" below:

Screenshot 2026-10-01 at 15 59 49

There is more red bellow, because pygments recognises the Python words (and so, they are not generic): Screenshot 2026-10-01 at 16 03 35

The image above is from here:
https://output.circle-artifacts.com/output/job/8a136c6d-99bb-4213-88a2-0a1299751a42/artifacts/0/doc/modules/generated/sklearn.base.RegressorMixin.html

EDIT:
The background is different because of the same issue we had with the themes currently used on main (it's the fault of a <pre>). I need to find where I talked about this.

EDIT2: about the background: #34484 (comment)

@DeaMariaLeon

Copy link
Copy Markdown
Member Author

I forgot: we could change what is purple to black if we wanted, by modifying custom.css as we did for the background. (That background color is removed from custom.css on this PR).

@lorentzenchr

lorentzenchr commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

I agree, as much as I like purple, it is a bit much purple.
I find it disturbing that variables are purple, too. For instance:

estimator=MyEstimator(param=0)

The variable estimator is as purple as the class MyEstimator (and param is purple, too).

NB: Interesting, here on github it is not that purple.

@DeaMariaLeon

DeaMariaLeon commented Oct 5, 2026 •

Copy link
Copy Markdown
Member Author

Yeah, it seems that Pygments doesn't recognize scikit-learn's methods, so it styles them as "generic". Every token ends up generic.

I also think that if we changed the text from purple to black in the theme we're trying, the contrast would fail accessibility checks as well. So we'd need to add our own background color, which would have to go in the custom.css file (and we want to avoid that).

We may need to try another theme.

@DeaMariaLeon

Copy link
Copy Markdown
Member Author

I'm off for a few days. I'll run some experiments when I'm back.

@DeaMariaLeon

Copy link
Copy Markdown
Member Author

@DeaMariaLeon DeaMariaLeon changed the title DOC Use GitHub-style high-contrast themes for code syntax highlighting DOC Use different themes for code syntax highlighting Oct 21, 2026
@DeaMariaLeon

Copy link
Copy Markdown
Member Author

Friendly ping to @lorentzenchr since I'm bugging you in other places.
I wonder if you saw my previous comment, or if you didn't like the new resulting highlight.

@lorentzenchr

Copy link
Copy Markdown
Member

I used a11y-high-contrast-light and dark.

What do you think? https://output.circle-artifacts.com/output/job/9e3f061e-e7c8-400d-ba29-e66ed9fc2dc7/artifacts/0/doc/auto_examples/release_highlights/plot_release_highlights_0_24_0.html

MAIN
image

THIS PR
image

Details

MAIN
image

THIS PR
image

Conclusion:
I prefer this PR. If you compare closely, this PR does not highlight the class RandomForestClassifier (and others). If this could also be fix, that would be the 100% solution. But I am also ok with 80-90% 😏

@DeaMariaLeon

Copy link
Copy Markdown
Member Author

If this could also be fix, that would be the 100% solution.

There is no fix that I know of. Please see comment for more details.

@betatim

betatim commented Oct 27, 2026

Copy link
Copy Markdown
Member

Sad times, I find having the class names in a different colour adds readability/scan-ability. And because I don't care too much about the background colour, I'd vote for keeping main :-/

@DeaMariaLeon

Copy link
Copy Markdown
Member Author

It seems that the best action is no action then. It was fun while it lasted. 😉

Closing.

@github-project-automation github-project-automation Bot moved this from PR in progress to Done in Labs Oct 27, 2026
@lorentzenchr

Copy link
Copy Markdown
Member

@DeaMariaLeon Thank you nevertheless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants