Open PGimenez opened 1 year ago
Run into same issue. Decided to just drop syntax highlight
Wasted already whole week trying to get company docs up and running again, coz of different Nuxt and Docus bugs :|
I ended up switching to highlightjs. I tried following the markdown highlighter instructions but couldn't make it work, so I ended up modifying the default template to call highlightjs
after the page is loaded.
<script lang="ts" setup>
import { onMounted } from 'vue';
import hljs from 'highlight.js'; // Import highlight.js if needed
onMounted(() => {
console.log("mounted")
document.querySelectorAll('pre code').forEach((block) => {
hljs.highlightBlock(block);
});
});
</script>
<template>
<DocsPageLayout>
<slot />
</DocsPageLayout>
</template>
<style>
.hljs {
width: 100%
}
</style>
I got a similar issue, after upgrading docus theme to (v1.14.9) it fix the issue
return
at Object.getHighlightedAST (./node_modules/@nuxtjs/mdc/dist/runtime/shiki/highlighter.mjs:44:7)
at <anonymous> (./node_modules/@nuxtjs/mdc/dist/runtime/shiki/event-handler.mjs:16:12)
at async Object.handler (./node_modules/h3/dist/index.mjs:1630:19)
at async toNodeHandle (./node_modules/h3/dist/index.mjs:1840:7)
[nuxt] [request error] [unhandled] [500] No grammar provided for <source.python>
after upgrade, no more issue
If I try to highlight a language other than the default like html or js, the site stops working and it can't be built. The browser shows a 404:
To attempt to debug this, I've started a docus project from scratch with
npx nuxi@latest init docs -t themes/docus
and added a snippet to the index pageAnd this is the error I'm getting when
npm run dev
It seems that the error is related to grammar files, but I don't know how to fix it. I've tried downgrading to earlier shiki versions but that didn't fix it.