Skip to content

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

ParameterType
optionsVizelCodeBlockOptions

Returns

Promise&lt;Node&lt;CodeBlockLowlightOptions, any&gt;[]&gt;

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 }),
];

Released under the MIT License.