svelte-markdoc-preprocess icon indicating copy to clipboard operation
svelte-markdoc-preprocess copied to clipboard

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

Open islamzaoui opened this issue 1 year ago • 1 comments

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

islamzaoui avatar Sep 24 '24 23:09 islamzaoui

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

TorstenDittmann avatar Oct 02 '24 17:10 TorstenDittmann

It's released now, not 100% happy yet with the implementation. Will wait a bit on adding it to the docs, however, you can use it and its passed as the default slot 👍🏻

TorstenDittmann avatar Oct 13 '24 15:10 TorstenDittmann