Frederisk/Wikitext-VSCode-Extension

Math remains dark when using dark-themed vscode

ARLundborg opened this issue · 2 comments

I'm currently editing a wiki page that includes some math text while using vscode in dark mode.

Say I write a piece of math:

:  <math>
1+1=2
</math>

Here's an image of how this looks in my editor together with that same math written in text above:

Screenshot 2021-01-20 at 11 21 55

Am I missing an option or is this a bug?

This is a known problem, which occurs because WebView will apply VSCode's theme CSS by default. I have considered implementing a general method to solve the problem many times in the past, but many methods do not work well in most cases. I will explain the problem:

Strictly speaking, this should be a problem that should be solved on the MediaWiki website you are logging in, that is, the website you are on should support the dark theme. If this is the case, when your VSCode uses a dark theme, the extension will try to call the website to return the CSS of the dark theme. The light theme of VSCode corresponds to the light theme of the website.

This method seems great, so I originally planned to do it the same way. Unfortunately, many websites I have learned do not achieve this. They only support light themes. Even Wikipedia does not have dark themes, unless users modify user CSS or use browser extensions.

So at present, it would be futile for me to add such a setting, and users simply cannot get the correct theme CSS. As the most direct and effective alternative, and also the worst, is to provide an option to directly turn off the default CSS provided by WebView in VSCode. Of course in this case you will probably get a preview page that will always be a light theme.

In my original plan, I actually left this problem to the user. Users can freely switch between light and dark themes of VSCode to get a normal and unified theme style. And I plan to provide a more accessible option in the sidebar in a major future version to allow users to change the WebView theme.

However, due to various reasons, including my busy work, this project has been slow. So after you raise this issue, I might consider temporarily providing such an option to turn off the default CSS.

Thanks a lot for taking the time to explain the problem. That makes a lot of sense. Even if dark mode is not feasible for wiki pages with math, I think any user editing such a page would greatly appreciate any (even temporary) fix.

Big fan of the extension!