fix(code): inherit container background and adjust line number color#4816
Open
Helbronner wants to merge 3 commits into
Open
fix(code): inherit container background and adjust line number color#4816Helbronner wants to merge 3 commits into
Helbronner wants to merge 3 commits into
Conversation
Using a custom `formatter_style` (such as a light theme) was previously overridden by the hardcoded dark `ManimCommunity#222` default `fill_color`. This change dynamically extracts the native `background_color` attribute from the specified Pygments style to ensure the container matches the theme. Additionally, updated the line number color logic: it now respects the color defined by the active Pygments style, falling back to `GRAY` if unspecified, preventing invisible white text on light backgrounds. Fixes ManimCommunity#4811
Previously, user-defined background `fill_color` was accidentally overridden by the default fallback color. This fix ensures that the custom value is preserved, passing the related test assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview: What does this pull request change?
This pull request fixes an issue (#4811 ) where custom
formatter_style(especially in a light theme likexcode) was previously overridden by the hardcoded darkManimColor("#222")defaultfill_color. It also updates the line number color logic to dynamically respect the active Pygments style.Fixes #4811
Motivation and Explanation: Why and how do your changes improve the library?
Previously, specifying a light
formatter_style(e.g.,xcode) resulted in an incorrect dark container background because of the hardcodedManimColor("#222")default.This pull request resolves the issue by dynamically extracting the native
background_colorfrom the active Pygments style. Additionally, line number colors are now dynamically fetched from the style context (falling back toGRAYif unspecified) to prevent invisible white text on light backgrounds.Q&A
Q: Why is the
fill_colorattribute preserved instead of deleted?A: To maintain backward compatibility. While deprecating
fill_coloraligns with the WYSIWYG principle (since Pygments styles should dictate the theme), removing it immediately would break existing user configurations. It is recommended to deprecate this attribute now and remove it during a future major refactor of the Code class.Links to added or changed documentation pages
Further Information and Comments
Verification
This fix successfully resolves the issue. Below is the demonstration of the expected behavior:
Test.mp4
Test Comparison
Test Script
Code for verifying the fix
Related Resources
Reviewer Checklist
Thanks for your time and review!