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.

CSS in JS syntax highlight is broken on Prism

See original GitHub issue

Describe the bug

I try to highlight styled-components code with function, code got unexpected.

To Reproduce Steps to reproduce the behavior:

  1. append like those code
const Item = styled.div`
  grid-row: ${({ row }) => row};
  grid-columns: ${ ({ col }) => col};
`
  1. wrap with Prism syntax highligter
    <SyntaxHighlighter language={"js"} style={prismStyle}>
      {code}
    </SyntaxHighlighter>
  1. got unexpected code
const Item = styled.div`
grid-row: ___CSS_0___;
grid-columns: ___CSS_1___;
`

Expected behavior I want to get like higlight.js version result.

const Item = styled.div`
  grid-row: ${({ row }) => row};
  grid-columns: ${ ({ col }) => col};
`

Screenshots https://stackblitz.com/edit/react-tjouhm

スクリーンショット 2019-10-30 17 50 28

Desktop (please complete the following information):

  • OS: Mac
  • Browser chrome,
  • Version: 77.0.3865.120

Smartphone (please complete the following information):

  • Device: iPhone6 SE
  • OS: iOS 13.1.3
  • Browser chrome
  • Version 78

Additional context Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
simmerercommented, Aug 13, 2020

Hey @jack-bliss, I’ll try to take a look at this soon! Thanks for your patience.

0reactions
jack-blisscommented, Mar 31, 2020

any word on this? I love that prism is highlighting my css in js rather than just leaving it as a string. it’s not blocking for me because i’m happy to just tweak my examples, but it’s definitely limiting and could become annoying down the road.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PrismJS syntax highlighting is broken due to conflicts with Bulma
There are at least 2 workarounds. Workaround #1. PrismJS adds token class to all highlighted elements including number and tag unlike Bulma.
Read more >
Syntax highlighting working only on first occasion #1301
I am using PrismJS on my website for code blocks. Issue is, on Chrome on Windows 7, Syntax highlighting and line numbering working...
Read more >
Syntax Highlighting (and More!) With Prism on a Static Site
This post will show you how to implement syntax highlighting on a Next.js blog with the popular Prism.js library.
Read more >
Solved: Re: RoboHelp 2020 > Frameless > Syntax Highlighter...
I'm using Prism.JS (https://prismjs.com/) to generate syntax highlighting for XML markup in the docs I'm writing. Locally, this all works well and looks ......
Read more >
Prism.js
Dead simple Include prism.css and prism.js, use proper HTML5 code tags ... The Prism source, highlighted with Prism (don't you just love how...
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