Skip to content

PluginMarkdownCodeBlockProcessorRegistrar

A registrar for markdown code block processors.

Obsidian ties a processor registered through Plugin.registerMarkdownCodeBlockProcessor to the plugin’s unload, so a component that registers one from its own onload and is later unloaded while the plugin stays loaded leaves the processor behind, and registering the same language again throws Code block postprocessor for language ... is already registered. A lifetime owner ties the processor to that component instead.

Import:

import { PluginMarkdownCodeBlockProcessorRegistrar } from '@mnaoumov/obsidian-lib/markdown-code-block-processor-registrar';

Signature:

export class PluginMarkdownCodeBlockProcessorRegistrar implements MarkdownCodeBlockProcessorRegistrar

Implements: MarkdownCodeBlockProcessorRegistrar

Constructor

new PluginMarkdownCodeBlockProcessorRegistrar(plugin: Plugin, options?: PluginMarkdownCodeBlockProcessorRegistrarConstructorOptions | undefined)

Creates a new markdown code block processor registrar.

Properties

PropertyTypeDescription
pluginPluginThe Obsidian plugin instance the code block processors are registered with.
registerMarkdownCodeBlockProcessor(params: MarkdownCodeBlockProcessorRegistrarRegisterMarkdownCodeBlockProcessorParams) => MarkdownPostProcessorRegisters a markdown code block processor.
(Inherited from MarkdownCodeBlockProcessorRegistrar)

Methods

MethodReturnsDescription
registerMarkdownCodeBlockProcessor(params)MarkdownPostProcessorRegisters a markdown code block processor, unregistered when its lifetime owner unloads.

Does nothing, and returns a no-op processor, when the plugin instance or the lifetime owner is not loaded. Obsidian 1.15.1's Component.register keeps a cleanup handed to an unloaded component without ever running it, so a processor registered by an instance that was unloaded while it was still loading (a plugin update, an install over an existing copy, a Hot Reload) would stay in Obsidian's global language map for the rest of the session, and the next registration of the same language would throw Code block postprocessor for language ... is already registered.