Skip to content

Plugin.registerMarkdownCodeBlockProcessor method

Plugin › registerMarkdownCodeBlockProcessor

Official

Register a special post processor that handles fenced code given a language and a handler. This special post processor takes care of removing the <pre><code> and create a <div> that will be passed to the handler, and is expected to be filled with custom elements.

Signature:

registerMarkdownCodeBlockProcessor(language: string, handler: (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => void | Promise<unknown>, sortOrder?: number | undefined): MarkdownPostProcessor

Parameters:

Parameter Type Description
language string The language of the code block to register.
handler (source: string, el: HTMLElement, ctx: MarkdownPostProcessorContext) => void | Promise<unknown> The handler to register.
sortOrder? number | undefined The sort order of the post processor.

Returns: MarkdownPostProcessorThe code block processor.

Since: 0.9.7

Example:

plugin.registerMarkdownCodeBlockProcessor('foo', (source, el, ctx) => {
el.createEl('strong');
});