-
Notifications
You must be signed in to change notification settings - Fork 24
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 syntax highlighting differs drastically between editing and reading modes #39
Comments
Thanks for reporting this. I haven't yet had the time to deep dive into this, but looking into other themes, even the default Obsidian theme, this behavior seems to be pretty much present in whatever theme I test. Mostly with the same colors even. |
I've yet to find an example of a theme that manages to make codeblocks look the same in preview and editing form and I think I see why. In the editing view, the input variables to your example would be themeable as But in the reading view, function variables aren't "adressable" at all, making them use the standard text color: And the function itself in the editing view would be While in the reading view, this would be themed via So I can make sure that Dracula colors are used "wherever possible" in code spans, but I doubt I'll be able to make them look identical in both views, while following the original Dracula color guides. |
Thanks for taking a look. Is this a bug in Obsidian's reading view, then? |
I hesitate calling it "bugged", but the way Obsidian renders the reading view does make it difficult to impossible to keep the coloring exactly the same for code blocks. I'll add overrides for the colors that can be themed so they at least match Dracula theming though. |
Thanks! |
I added code block theming with Version Tried to align the code views as best as Obsidian allows. In the editing view, many things share the same CSS tag, namely This is an example of the Dracula theme with your example in VSCode: This is what the editing view looks like now (Most of what shows up as the white foreground color uses the Reading view looks pretty similar, but for example the "None" in line 15 is themed as a I gotta admit though, I leaned heavily on your example and haven't gone out of my way to look for all possible keywords that might require theming. If you have example code where portions stick out after |
This looks great. Thanks! |
These changes indeed look awesome ! |
@EDM115 That's a good point. In IDEs using Dracula, the background is the same color as the whole page in Obsidian, so making it lighter behind code listings tends to wash out the colors. I wonder if the background color could be darker as a way to offset the code blocks from text? |
Well I believe the background color is already Background ( |
Good points both. Maybe there is a way to put a border of the lighter background color around the code blocks, instead of changing the background entirely? Let me try a few mockups of what might work. |
When I'm working with notes that contain code blocks, the syntax highlighting of the code is very different between the editing and reading modes.
My expectation is that the syntax highlighting would use the same highlighting in both editing and reading modes.
I'm not sure which version is intended to be the "correct" form of syntax highlighting, but the highlighting I see in editing mode looks nicer (to me).
Example of syntax highlighting in editing mode
Example of syntax highlighting in reading mode
Reference source
For reference, here is the Markdown source I used in the example screenshots:
The text was updated successfully, but these errors were encountered: