question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[gatsby-remark-prismjs] `diff` with language / highlight

See original GitHub issue

Hi there!

Trying to understand a few things related to gatsby-remark-prismjs and how it may (or may not) differ from regular prismjs.

The prism site has an example of diff-highlighting and I’m trying to recreate that in my site (here’s my post).

Github’s preview is a good example of what I’m striving for: Github Preview

On my site, however, I can’t seem to figure out how to get highlights - whether language specific or not: Screen Shot 2020-01-15 at 2 26 31 PM

I’ve tried

```diff-javascript
```diff javascript

And several other variants, but to no avail.

Interestingly, diff-javascript results in some weird encoding (note the undefined values that get appended to the ends of lines):

Screen Shot 2020-01-15 at 2 29 23 PM

My questions:

  1. Does gatsby-remark-prismjs support multi-language (diff + javascript for example)?
  2. Does gatsby-remark-prismjs support line-highlighting (with the green/red, not the standard highlighting)?

Thanks!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jon-sullycommented, Apr 20, 2021

Oh I see — this is coming from a separate, additional plugin.

https://github.com/DSchau/gatsby-remark-code-titles

I checked the code of that plugin just briefly and I don’t think there’s anything that should necessarily change how it works with gatsby-remark-prismjs. If it works for you now it should continue to without issue.

Feel free to pull down @jonsully/gatsby-remark-prismjs (latest version) and give it a try though

1reaction
jon-sullycommented, Apr 19, 2021

Greetings 👋🏻

This bothered me too, especially since I don’t use the line-highlighting implemented by this plugin. ~I modded a bit of the diff-sniffing code behind this plugin and published a variant (REVOKED) that injects the diff-highlight class. I likely won’t PR this repo with the changes because they’re not the cleanest and it sort of goes against Commonmark spec, but you’re welcome to use it if you’d like~:

~Give it a try if ya like. Your mileage may vary~

EDIT: Removed the above; this was a bad direction. I’ve since iterated and PR’d this repo with more reasonable and better changes. Instructions for installing until the PR is merged coming soon 👍🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improving Prism diff syntax highlighting in Gatsby
Tweaking Prism and Gatsby to improve the syntax highlighting of diffs (works on Next.js and other framework too).
Read more >
gatsby-remark-prismjs
gatsby -remark-prismjs Adds syntax highlighting to code blocks in markdown files ... blocks by using diff-[language] to enable syntax highlighting in diffs:.
Read more >
5 ways to improve your Gatsby code blocks - Emma Goto
Use syntax highlighting with gatsby-remark-prismjs. Syntax highlighting changes the colour of parts of your code to make it more readable. It's ...
Read more >
gatsby-remark-prismjs @ 3.2.7 .. 3.2.8 - Package Diff
Visual diff of the npm package 'gatsby-remark-prismjs' comparing 3.2.7 with ... +module.exports = (language, code, lineNumbersHighlight = [] ...
Read more >
gatsby-remark-prismjs/README.md - UNPKG
1, # gatsby-remark-prismjs. 2. 3, Adds syntax highlighting to code blocks in markdown files using. 4, [PrismJS](http://prismjs.com/).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found