-
Notifications
You must be signed in to change notification settings - Fork 201
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
IMPROVE: Harmonize themes between static and live code #393
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
Thanks for the PR! A few comments:
I think the main thing I'm worried about is that this is some special-case CSS that will be very hard to notice/test if there's a regression. I also want to throw out one other possibility that didn't come to mind before: what if we went in the other direction, and instead of making the CodeMirror CSS match the book theme CSS, we made minor modifications to the book theme code cells CSS to make it match one of the more popular CodeMirror styles? |
There's a lot more CSS classes in pygments than in CM5, so it was simpler to write it in this direction. If there's good reason to do the reverse, that would also work. I do think that static code is far more used than live code, and the CM -> pygments route would affect many more downstream people, so I think the surface is smaller for CM -> pygments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this looks good to me - just one quick comment to add more context for folks.
One thing we should flag is if we ever change the static code cell style, we'll also need to update these styles as a result. One case where I could imagine this happening is if we use a "dark mode toggle" that might affect code cells as well.
Co-authored-by: Chris Holdgraf <choldgraf@gmail.com>
Just one thing before - what would be the ideal location to put the link to the stylesheet? Right now it's in footer.html, there is probably a better spot for it. |
@patrickmineault hmmm good question, this relates to another thought that I had as well actually. If we bundle this CSS then will it clobber any theme changes that people select for CodeMirror? If somebody explicitly says "I want a specific CodeMirror theme" then I think that we should make sure they get it, not force them to use this style. Answering that question might impact where this CSS gets loaded |
@choldgraf good point - I will check how this integrates with the |
cool - perhaps we could just add some conditional logic that checks whether |
I found an issue trying to integrate with jupyterbook: it turns out pygments_style is |
huh - that is strange...did you find where they were configured? I would have assumed that Jupyter Book just inherits whatever comes from the book theme. My feeling is that we should modify Jupyter Book to just "use whatever the default in the book theme is". Other themes may want to define their own behavior with pygments, so that shouldn't be defined at the Jupyter Book level IMO |
In sphinx-book-theme, it's defined in I thought I could define which one is the canonical styling as whichever one matches jupyterlab. However, it turns out jupyterlab uses a 4th style unlike the first three encountered so far: I'm starting to think that maybe this is a rabbit hole I shouldn't go down further. What I could do instead is remove the attempt to change the colors, only fix the spacing and font, and add a little bit of CSS so that when you have a cell highlighted it does the same as in jupyterlab, that is make the cell background white and put an outline around it. |
Ok, how about this? This improves the match of the look of the live code cells compared to static code cells. It also improves the usability of the code cell by changing the background to white and putting an outline around the cell. I doesn't attempt to match the colors, since this appears to open up a can of worms. |
I think that this looks quite nice - and avoids us needing to deal with the extra complexity of special-casing theme choices and such. I'm +1 on it if you think that this still works for you :-) |
Yeah, this is def an improvement! I've moved all the css to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks really nice - it is a good compromise between extra complexity and making obvious incremental improvements. I'll merge it in once the tests are happy!
thanks for this improvement! |
As mentioned in executablebooks/sphinx-thebe#39, there is a discrepancy between how static code and live code look in the sphinx book theme. This PR patches CodeMirror CSS to match the pygments css. It's not perfect, but it's hard to distinguish the two with the naked eye.
Before,
thebe.md
(static on top, live at bottom):After:
Seeking guidance: right now the CSS is patched at the worst possible spot in the footer - would like to know where to put it in, or whether to split off the CSS in a couple of different places. Also would like to know if the test
thebe.md
file should be put in the docts or put in a test folder somewhere.