remark-prism | Syntax highlighter for markdown code blocks using Prism
kandi X-RAY | remark-prism Summary
kandi X-RAY | remark-prism Summary
Syntax highlighter for markdown code blocks using Prism
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of remark-prism
remark-prism Key Features
remark-prism Examples and Code Snippets
const src = `
\`\`\`javascript
console.log('Hello World');
\`\`\`
`;
require('unified')()
.use(require('remark-parse'))
.use(require('remark-stringify'))
.use(require('remark-prism'), {
/* options */
})
.use(require('remark-html'))
.
use(require('remark-prism'), {
plugins: [
'autolinker',
'command-line',
'data-uri-highlight',
'diff-highlight',
'inline-color',
'keep-markup',
'line-numbers',
'show-invisibles',
'treeview',
],
});
use(require('remark-prism'), {
transformInlineCode: true,
});
Community Discussions
Trending Discussions on remark-prism
QUESTION
"gatsby develop" works well. However, an error occurs in 'gatsby build'
...ANSWER
Answered 2022-Mar-30 at 05:45Summarizing a lot gatsby develop
is interpreted by the browser while gatsby build
is compiled in the Node server (your machine or your deploy server) so the behavior of your code is slightly different. Especially to what's related to global objects and SSR (Server-Side Rendering). The fact that your code works under gatsby develop
means that is working under certain specific conditions, not that your code works always or has no errors, this should be inferred if it succeeds in a gatsby build
.
In your case, it seems that the posts
data is undefined
when using memoized hook (useMemo
), at least, in the initial render.
Try using:
QUESTION
I wanted to convert markdown to syntax highlighted HTML with remark and remark-prism. But it doesn't work.
code:
...ANSWER
Answered 2022-Feb-09 at 12:11According this site, change just like below code, the code correctory work.
QUESTION
After migrating from Remark to MDX, my builds on Netlify are failing.
I get this error when trying to build:
...ANSWER
Answered 2022-Jan-08 at 07:21The problem is that you have Node 17.2.0. locally but in Netlify's environment, you are running a lower version (by default it's not set as 17.2.0). So the local environment is OK, Netlify environment is KO because of this mismatch of Node versions.
When Netlify deploys your site it installs and builds again your site so you should ensure that both environments work under the same conditions. Otherwise, both node_modules
will differ so your application will have different behavior or eventually won't even build because of dependency errors.
You can easily play with the Node version in multiple ways but I'd recommend using the .nvmrc
file. Just run the following command in the root of your project:
QUESTION
There's an issue with gatsby-plugin-sharp
(or more specifically sub-dependency mozjpeg
) whereby it'll give the exception autoreconf: not found
, but the issue is actually with other dependencies. There are various posts where people have found one combination or another of various dependencies to get it to work for them (eg https://stackoverflow.com/a/66170062/2475012, https://github.com/gatsbyjs/gatsby/issues/19432#issuecomment-553644600). But there doesn't seem to be a definitive list anywhere of the exact dependencies you need.
I'm running Gatsby on GitHub Actions on ubuntu-latest
. My package.json
:
ANSWER
Answered 2021-Mar-08 at 06:24gatsby-plugin-sharp
, according to the documentation:
@babel/runtime
async
bluebird
filenamify
fs-extra
gatsby-core-utils
gatsby-telemetry
got
imagemin
imagemin-mozjpeg
imagemin-pngquant
lodash
mini-svg-data-uri
potrace
prob-image-size
progress
semver
sharp
svgo
uuid
- Dev dependencies:
@babel/cli
,@babel/core
,@types/sharp
,babel-preset-gatsby-package
,cross-env
,gatsby-plugin-image
,gatsby-plugin-utils
On the other side, mozjpeg
has:
bin-build
bin-wrapper
logalot
- Dev dependencies:
ava
,bin-check
,compare-size
,execa
,tempy
,xo
QUESTION
I am using Gatsby Plugin sharp with other plugins for remark images. Package json provided below.
Strangely the build goes through fine on MacOS but fails inside the Debian docker container while try to fetch metadata for a PNG image. This error is faced by gatsby-plugin-sharp
package.json - only dependencies included
...ANSWER
Answered 2021-Feb-12 at 10:22Ended up solving this - Leaving the cause of issue here so that it can help others - I was using a NodeJS - 15.8.0-slim base image. Gatsby Plugin Sharp is dependent on C libraries and binaries behind the scenes which were not really included in the Slim base image. I used 15.8.0-buster image and it worked all good.
The log was extremely misleading and ended up wasting a lot of my time. Hope this saves the time of anyone else who ends up with this.
QUESTION
I am building a static website with Gatsby and Netlify CMS. The website is hosted on Netlify as well. I have a blog section and I generate a page per article from a markdown file. I have the following warning during build "query takes too long" for every article page I generate. The site builds eventually but the build time gets longer and longer the more pages I am generating so I'm afraid it will become too long when I start having too many articles in my site.
I am generating a page for each markdown file that is being created by netlify CMS.
Would you mind looking and the code I have in the gatsby-node file and the query I am using in my blog template file to see if I'm doing anything wrong that would explain the build time warning message ?
Thanks
Here is my development environment
...ANSWER
Answered 2021-Feb-01 at 16:49Gatsby's team is actually working on reducing the build time by adding some "cache" features. You can follow the stack trace in their releases notes, they are still in beta testing (some of them are focused mainly on gatsby develop
.
If you want to try it them to check if it improves the build-develop time, you just need to upgrade Gatsby to the latest version (^2.28
) and:
QUESTION
Hi. I have a Gatsby website and I am making use of the gatsby-transformer-remark
plugin to get a load of blog markdown files from a blog directory into GraphQL to display on my site. I have looked at the docs and example code to see how to create a slug for each page so that in the gatsby-node.js
file I can create pages with the slug dynamically.
When I try to access the fields { slug }
property in GraphiQL I get the following error:
message": "Cannot query field \"fields\" on type \"MarkdownRemark\"."
I have checked my setup a couple of times and I think it all seems good so I'm not 100% sure what I have missed to not have these fields. I can access other informations such as the raw content of the markdown files and the frontmatter data, just not the fields.
In My gatsby-config.js
plugins I have the following setup for the source filesystem and the remark plugin
ANSWER
Answered 2021-Jan-04 at 08:12As you can see, slug
field is not a child of frontmatter
(as natively should if you work with raw markdowns). To make the slug
available as children of field
, you need to add the following snippet in your gatsby-node.js
:
QUESTION
I am unable to install the Gatsby plugin for Netlify CMS
to my blog. I've been following a tutorial of adding Netlify CMS to existing blog and also referred to this doc.
Here's a link to my repo: https://github.com/mohammedasker/blogger
- Clone my repo and head to the project directory
- run
npm install --save netlify-cms-app gatsby-plugin-netlify-cms
Gatsby plugin for Netlify CMS
installed successfully.
Error in installing Gatsby plugin for Netlify CMS.
Here's the error log I got from the terminal:
...ANSWER
Answered 2020-Jul-27 at 20:27Installing the Gatsby plugin for Netlify CMS
plugin before running gatsby develop
has solved the problem.
QUESTION
i'm using the gatsby starter blog template to create a personal blog. I have made modifications to enhance a few features, though I haven't made any changes to image handling.
With that said, images do not seem to be rendering on the page when createPage is constructing log posts from the markdown files.
Markdown file image call
![linksx](./links.jpg)
![links1](../pages/roam-research-intro/links1.jpg)
Here I'm trying out if the image needs to be I the same folder as the markdown file, or in the same folder as the page template - neither works.
Files
Gatsby config
...ANSWER
Answered 2020-May-04 at 07:47Since both markdown and images are in the same directory you can simply specify the image like below
QUESTION
I am revamping a blog to Gatsby which is lightning fast, everything seems perfect but I am facing different sort of issue, as the images I have via Netlify CMS aren't appearing properly in the blog, the images are appearing blur. I don't know what is going wrong here.
Here is the example of the problem statement
here is the excerpt of my gatsby-config.js.
...ANSWER
Answered 2020-Mar-24 at 06:16I am more interested in how do you call those images in your components rather than in the package.json
(it doesn't seem a dependencies issue) because inspecting the code, it seems that you've added the /static
path which is not required. As it is shown in the following screenshot:
Regarding the updates coming from the comments below, we've figured out that the issue is related directly to this GitHub issue where apparently images retrieved by a markdown are blurring. What solves the issue is to pass a withWebp
parameter in Gatsby's configuration, so in gatsby-config.js
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install remark-prism
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page