Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support more code type #1265

Closed
Benbinbin opened this issue Jun 16, 2022 · 4 comments · Fixed by #1278
Closed

Support more code type #1265

Benbinbin opened this issue Jun 16, 2022 · 4 comments · Fixed by #1278
Labels
enhancement New feature or request

Comments

@Benbinbin
Copy link
Contributor

Benbinbin commented Jun 16, 2022

Is your feature request related to a problem? Please describe

When I write code block which type rarely seen in markdown file, like diff, the console throw an error in dev mode

[nuxt] [request error] No grammar provided for <source.[the name of the rarely seen code type]>

Describe the solution you'd like

It seems this error throw from shiki, how to config it to ignore the rarely code type instead of throw an error

Describe alternatives you've considered

Additional context

the markdown wrting code block as fellow, its type is diff, github and VS Code built-in markdown editor preview mode can render this type

Snipaste_2022-06-16_17-25-33

but the Nuxt console throw an request error and then a 500 Internal Server Error

Snipaste_2022-06-16_17-22-03

and the page cannot render correct

Snipaste_2022-06-16_17-24-32

@Benbinbin Benbinbin added the enhancement New feature or request label Jun 16, 2022
@farnabaz
Copy link
Member

This issue comes from Shiki itself. check upstream issue shikijs/shiki#257

Meanwhile, you can use highlight.preload to preload all required language. Check my comment #1225 (comment)

@Benbinbin
Copy link
Contributor Author

This issue comes from Shiki itself. check upstream issue shikijs/shiki#257

Meanwhile, you can use highlight.preload to preload all required language. Check my comment #1225 (comment)

just add 'diff' in content.highlight.preload is still not working, the console throw another error [nuxt] [request error] No grammar provided for <source.ts>

Maybe it needs more setting

@farnabaz
Copy link
Member

When you use preload config, you need to define list of languages you are using in your contents.

defineNuxtConfig({
  content: {
    highlight: {
      preload: ['diff', 'ts', 'js', 'css', ...]
    }
  }
})

@farnabaz
Copy link
Member

I just create a PR(#1278) to prevent this bad behavior, in next release you will not need to add ts or js into preload options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants