mjbvz / vscode-github-markdown-preview-style

VS Code extension that changes the built-in markdown preview to match Github's styling
https://marketplace.visualstudio.com/items?itemName=bierner.markdown-preview-github-styles
MIT License
301 stars 57 forks source link

Custom user styles not working #98

Closed seamusm02 closed 1 year ago

seamusm02 commented 1 year ago

Create a simple style.css as a test:

body { background-color: green}

With extension enabled, the extension overrides the custom style. With the extension disabled, the style is rendered correctly.

One of the features listed is

Customize styling using your own markdown.styles css

Am I misunderstanding something?

Markdown Preview Github Styling v1.0.1

VSCode / OS Version: 1.63.2 (user setup) Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3 Date: 2021-12-15T09:40:02.816Z Electron: 13.5.2 Chromium: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Windows_NT x64 10.0.19045

jjspace commented 1 year ago

It seems that styles are added to the markdown preview in the following order per the docs

However, the way this extension works is it wraps all the rendered markdown content in an extra div to be able to specify which theme to use (see img). This is why your style on body is being overridden. Change body to .github-markdown-body and I believe it should work

2023-03-27_13-55 The red box is the actual content which would be rendered in body if the extension is turned off

The code that does this can be seen here https://github.com/mjbvz/vscode-github-markdown-preview-style/blob/f2cb247f3e4094f729642b62d142b71aac5a3a08/dist/extension.js#L43-L47

It would probably be good to add something about this to the README so others don't have to dig into the code just to use that feature.

seamusm02 commented 1 year ago

Yup, that works! Thanks!