content icon indicating copy to clipboard operation
content copied to clipboard

R code highlighting error

Open jsandblom opened this issue 3 years ago • 4 comments

Environment

Nuxt CLI v3.0.0-rc.6
RootDir: /workspaces/js-n3
Nuxt project info:


  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules, content
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

Reproduction

Try the following on https://content.nuxtjs.org/playground

const a = 'javascript works great'
r <- 'R does not'

Describe the bug

R code is not highlighted. I could not find any console messages in the playground, but on github codespaces I get lots of

[nuxt] [request error] No grammar provided for <source.r> at Registry.e._collectDependenciesForDep (./node_modules/shiki-es/dist/shiki.mjs:12:24999)
at Registry. (./node_modules/shiki-es/dist/shiki.mjs:12:25495)
at ./node_modules/shiki-es/dist/shiki.mjs:12:23016
at Object.next (./node_modules/shiki-es/dist/shiki.mjs:12:23125)
at s (./node_modules/shiki-es/dist/shiki.mjs:12:21828) [nuxt] [request error] 500 Internal Server Error (/api/_content/highlight) at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async highlightBlock (./.nuxt/dev/index.mjs:2633:17)
at async Promise.all (index 0)
at async Object.transform (./.nuxt/dev/index.mjs:2602:5)
at async parseContent (./.nuxt/dev/index.mjs:2666:18)
at async getContent (./.nuxt/dev/index.mjs:2745:18)
at async Promise.all (index 0)
at async getContentsList (./.nuxt/dev/index.mjs:2715:20)
at async ./.nuxt/dev/index.mjs:541:18
at async ./.nuxt/dev/index.mjs:2830:20

Additional context

No response

Logs

No response

jsandblom avatar Aug 10 '22 18:08 jsandblom

Sorry, I assumed the text in "Reproduction" would not be formatted. The first language block should obviously be "js" and the second "r".

jsandblom avatar Aug 10 '22 18:08 jsandblom

Also I should mention that shiki appears not to be to blame, as R code is properly highlighted here: https://codesandbox.io/s/shiki-next-js-forked-jc1yuc?file=/pages/index.js

jsandblom avatar Aug 10 '22 18:08 jsandblom

you should setting the highlight language at nuxt.config.ts

check this issue for more detail

this is the live demo

Benbinbin avatar Aug 11 '22 02:08 Benbinbin

Indeed! Thank you. This was however not easily seen in the documentation.

Johan

jsandblom avatar Aug 11 '22 04:08 jsandblom