-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[gatsby-remark-prismjs] Code highlighting is not getting applied #26768
Comments
Hi @AbbottSoft! Can you provide sample repository showing this problem? I just tried using Tested content:
Which I think is what you would expect, but it's not what you get in your case. One thing to check for sure is to investigate styles in dev tools. Particularly styles for And all of those come from prism css theme file. I think in this case something with higher css specificity overwrites the |
Hey @pieh! Here is a reproduction of the bug in question. https://github.com/AbbottSoft/issue28768 Hope this helps! |
Looks like I am not getting any of the classes applied to the |
I was able to resolve this issue and my problem could not have been simpler. My {
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
"gatsby-remark-graphviz",
`gatsby-remark-responsive-iframe`,
`gatsby-remark-prismjs`,
{
resolve: `gatsby-remark-images`,
options: {
// It's important to specify the maxWidth (in pixels) of
// the content container as this plugin uses this as the
// base for generating different widths of each image.
maxWidth: 590,
},
},
],
},
}, I was surprised a problem like this didnt throw an error in the gatsby dev server since it seems all plugins which take the object syntax seem to require the resolve and options property. Maybe this would be a useful addition to log when someone accidentally puts the plugins property in the wrong spot with a helpful message? Closing this issue for now. |
Description
Currently, I am using
gatsby-remark-prismjs
in order to add style to code blocks. I would expect that my theme would apply the styles, but currently I get just white text.Steps to reproduce
Create a markdown file with a code block inside and put it in
src/posts/{filename}
using the default gatsby starter. Apply the queried html usingdata.markdownRemark.html
and usedangerouslySetInnerHTML
prop on a div to apply the converted markdown. Use the following configurations below.Dependencies in package.json:
gatsby-config.js
gatsby-browser.js
Expected result
I would expect my code blocks to have some degree of syntax highlighting and at least a background color change.
Actual result
I get no syntax highlighting and white text.
Environment
System:
OS: macOS 10.15.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.8.0 - ~/.nvm/versions/node/v14.8.0/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.14.7 - ~/.nvm/versions/node/v14.8.0/bin/npm
Languages:
Python: 3.7.3 - /Users/myusername/.pyenv/shims/python
Browsers:
Chrome: 85.0.4183.83
Firefox: 80.0
Safari: 13.1.2
npmPackages:
gatsby: ^2.24.47 => 2.24.47
gatsby-image: ^2.4.16 => 2.4.16
gatsby-plugin-catch-links: ^2.3.11 => 2.3.11
gatsby-plugin-emotion: ^4.3.10 => 4.3.10
gatsby-plugin-manifest: ^2.4.23 => 2.4.23
gatsby-plugin-offline: ^3.2.23 => 3.2.23
gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10
gatsby-plugin-sharp: ^2.6.27 => 2.6.27
gatsby-plugin-typescript: ^2.4.18 => 2.4.18
gatsby-remark-images: ^3.3.25 => 3.3.25
gatsby-remark-prismjs: ^3.5.10 => 3.5.10
gatsby-remark-responsive-iframe: ^2.4.12 => 2.4.12
gatsby-source-filesystem: ^2.3.24 => 2.3.24
gatsby-transformer-remark: ^2.8.28 => 2.8.28
gatsby-transformer-sharp: ^2.5.13 => 2.5.13
npmGlobalPackages:
gatsby-cli: 2.12.87
The text was updated successfully, but these errors were encountered: