Skip to content

registerInlineTokenRenderer

Registers an inline token in both Reading view and Live Preview, from one definition.

Obsidian ties both registrations to the plugin’s lifetime and offers no way to remove either earlier.

Import:

import { registerInlineTokenRenderer } from '@mnaoumov/obsidian-lib/inline-token-renderer';

Example:

registerInlineTokenRenderer({
editorExtensionRegistrar: new PluginEditorExtensionRegistrar(this),
markdownPostProcessorRegistrar: new PluginMarkdownPostProcessorRegistrar(this),
regExp: /:([a-z]+):/,
render({ containerEl, match }) {
containerEl.setText(EMOJI[match[1] ?? ''] ?? match[0]);
}
});

Signature:

function registerInlineTokenRenderer(params: RegisterInlineTokenRendererParams): void

Parameters:

Parameter Type Description
params RegisterInlineTokenRendererParams The registration parameters.

Returns: void

Example:

registerInlineTokenRenderer({
editorExtensionRegistrar: new PluginEditorExtensionRegistrar(this),
markdownPostProcessorRegistrar: new PluginMarkdownPostProcessorRegistrar(this),
regExp: /:([a-z]+):/,
render({ containerEl, match }) {
containerEl.setText(EMOJI[match[1] ?? ''] ?? match[0]);
}
});

Links to this page: