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

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

Closed
IslamZaoui opened this issue Sep 24, 2024 · 2 comments · Fixed by #237
Closed
Assignees
Labels
enhancement New feature or request

Comments

@IslamZaoui
Copy link

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 IslamZaoui changed the title Custom fence/codeblock highlighting function in preprocessor config Feature request: custom fence/codeblock highlighting function in preprocessor config Sep 24, 2024
@TorstenDittmann
Copy link
Owner

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

@TorstenDittmann TorstenDittmann added the enhancement New feature or request label Oct 2, 2024
@TorstenDittmann TorstenDittmann self-assigned this Oct 2, 2024
@TorstenDittmann TorstenDittmann linked a pull request Oct 13, 2024 that will close this issue
@TorstenDittmann
Copy link
Owner

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 👍🏻

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