Vizel API / core/src / createVizelCodeBlockExtension
Function: createVizelCodeBlockExtension()
ts
function createVizelCodeBlockExtension(options?): Promise<Node<CodeBlockLowlightOptions, any>[]>;Defined in: packages/core/src/extensions/code-block-lowlight.ts:161
Create the CodeBlockLowlight extension with syntax highlighting.
This function is async because lowlight is loaded dynamically as an optional dependency.
Parameters
| Parameter | Type |
|---|---|
options | VizelCodeBlockOptions |
Returns
Promise<Node<CodeBlockLowlightOptions, any>[]>
Examples
Basic usage
ts
const extensions = [
...await createVizelCodeBlockExtension(),
];With options
ts
const extensions = [
...await createVizelCodeBlockExtension({
defaultLanguage: 'typescript',
lineNumbers: true,
languages: 'all', // Load all 190+ languages
}),
];With custom lowlight instance
ts
import { common, createLowlight } from 'lowlight';
import typescript from 'highlight.js/lib/languages/typescript';
const lowlight = createLowlight(common);
lowlight.register('typescript', typescript);
const extensions = [
...await createVizelCodeBlockExtension({ lowlight }),
];