Skip to content
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

Custom user styles not working #98

Closed
seamusm02 opened this issue Feb 13, 2023 · 2 comments
Closed

Custom user styles not working #98

seamusm02 opened this issue Feb 13, 2023 · 2 comments

Comments

@seamusm02
Copy link

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
Copy link
Contributor

jjspace commented Mar 27, 2023

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

  • VSCode built in styles
  • Extension styles (these ones)
  • User styles in markdown.styles

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

md.renderer.render = function() {
return `<div class="github-markdown-body github-markdown-${getColorTheme()}">
<div class="github-markdown-content">${render.apply(md.renderer, arguments)}</div>
</div>`;
};

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
Copy link
Author

Yup, that works! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants