TorstenDittmann / svelte-markdoc-preprocess

Bring the power of Markdoc right into your Svelte applications!
https://svelte-markdoc-preprocess.pages.dev
MIT License
63 stars 4 forks source link

Feature request: custom fence/codeblock highlighting function in preprocessor config #229

Open IslamZaoui opened 1 week ago

IslamZaoui commented 1 week ago

Is your feature request related to a problem? Please describe. using shiki in fence component result in bad preformace in loading the page

Describe the solution you'd like better to use a highlighting function to avoid sending shiki to client like this example

//svelte.config.js
function customHighlighter (content: string, language:string ){
    return shiki.codeToHtml(content, {
        lang: language,
        theme: 'github-dark',
        transformers: [
            transformerNotationDiff(),
            transformerNotationErrorLevel(),
            transformerNotationHighlight()
        ]
    })
}

const config = {
    preprocess: [
        vitePreprocess(),
        markdoc({
            highlighter: customHighlighter
        })
    ]
}

Describe alternatives you've considered n/a

Additional context n/a

TorstenDittmann commented 2 days ago

It might be smart to add this, so far I have been relying on pre-rendering for this using SvelteKit 🤔