nextra icon indicating copy to clipboard operation
nextra copied to clipboard

No syntax hilight for code block

Open zhqu1148980644 opened this issue 4 years ago • 9 comments

I cloned this repo, run yarn add . and then yarn dev, code blocks in localhost website does not have highlights.

image

zhqu1148980644 avatar Jan 02 '21 13:01 zhqu1148980644

i trying to clone it, and when in npm run dev code blocks dont have highlights. But, trying upload in vercel / npm run build will has highlights, only in production

naufaldi avatar Jan 19 '21 17:01 naufaldi

Interesting, Im having the same issue, just the other way around, code highlighting works on localhost (next dev and next start) but as soon as I roll it out on prod, code highlighting does not work anymore.

I am using these prism imports

https://nextra.vercel.app/docs/advanced/code-highlighting

Before code highlighting did not work at all.

LucaNerlich avatar Mar 27 '21 12:03 LucaNerlich

ive just tested with deployment on vercel and code highlighting works here, it just looks a bit odd, since nextra uses a dark backround for code / pre blocks, which makes text unreadable.

LucaNerlich avatar Mar 27 '21 13:03 LucaNerlich

Can't reproduce this personally, I think more insights are needed from the community. Will keep eyes open on this!

shuding avatar May 19 '21 17:05 shuding

When I use npm install -> npm run dev, syntax highlighting does not work.

If I use yarn, then it works.

phc5 avatar Sep 23 '21 15:09 phc5

I'm having this issue as well. I'm trying to enable syntax highlighting for Swift. I followed the instructions and added the needed config to the _app.js file yet syntax highlighting does not work. Nor for Javascript code snippets.

Here's my _app.js file:

import Prism from 'prism-react-renderer/prism'
;(typeof global !== 'undefined' ? global : window).Prism = Prism

require('prismjs/components/prism-swift')

import 'nextra-theme-docs/style.css'
import '../styles/globals.css'

export default function Nextra({ Component, pageProps }) {
  return <Component {...pageProps} />
}

This is what gets rendered: Screen Shot 2021-11-20 at 12 15 32 PM

algoritmau avatar Nov 20 '21 17:11 algoritmau

I'm having the same issue with Swift syntax highlighting @spaceinvadev is experiencing.

daltonturner avatar May 19 '22 02:05 daltonturner

You may try the versions of packages used in https://github.com/shuding/site/blob/master/package.json if you cannot see the code highlighting in blog theme.

suica avatar May 29 '22 10:05 suica

You may try the versions of packages used in https://github.com/shuding/site/blob/master/package.json if you cannot see the code highlighting in blog theme.

This worked for me! Thank you, @suica!

daltonturner avatar May 29 '22 20:05 daltonturner

closing since works fine in beta 2

dimaMachina avatar Aug 20 '22 14:08 dimaMachina