Skip to content

MarkdownRenderer

Official

A renderer for markdown.

Import:

import { MarkdownRenderer } from 'obsidian';

Signature:

export class MarkdownRenderer extends MarkdownRenderChild implements MarkdownPreviewEvents, HoverParent

Extends: MarkdownRenderChild

Implements: MarkdownPreviewEvents, HoverParent

Constructor

new MarkdownRenderer(app: App, containerEl: HTMLElement, supportWorker?: boolean | undefined)

Constructor.

To extract the constructor type, use ExtractConstructor<MarkdownRenderer>.

Properties

Property Type Description
_children Component[] Child Components attached to current component, will be unloaded on unloading parent component.
(Inherited from MarkdownRenderChild)
_events EventRef[] Events that are attached to the current component, will be detached on unloading parent component.
(Inherited from MarkdownRenderChild)
_loaded boolean Whether the component and its children are loaded.
(Inherited from MarkdownRenderChild)
app App The Obsidian app instance.
containerEl HTMLElement The container element of the markdown render child.
(Inherited from MarkdownRenderChild)
hoverPopover HoverPopover | null The hover popover of the markdown renderer.

Methods

Method Returns Description
addChild(component) T Adds a child component, loading it if this component is loaded.
(Inherited from MarkdownRenderChild)
load() void Load this component and its children.
(Inherited from MarkdownRenderChild)
onCheckboxClick(e, n, i) unknown Handle a checkbox click event in the rendered markdown.
onFileChange(e) unknown Handle a file change event for the rendered file.
onFoldChange() unknown Handle a fold state change in the rendered markdown.
onload() void Called when the renderer is loaded.
onRenderComplete() unknown Called when the markdown rendering is complete.
onScroll() unknown Handle a scroll event in the rendered markdown.
onunload() void Override this to unload your component
(Inherited from MarkdownRenderChild)
postProcess(e, t, n) unknown Apply post-processing to the rendered markdown output.
register(cb) void Registers a callback to be called when unloading.
(Inherited from MarkdownRenderChild)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading.
(Inherited from MarkdownRenderChild)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from MarkdownRenderChild)
registerDomEvent(el, type, callback, options?) void Registers a DOM event to be detached when unloading
(Inherited from MarkdownRenderChild)
registerEvent(eventRef) void Registers an event to be detached when unloading.
(Inherited from MarkdownRenderChild)
registerInterval(id) number Registers an interval (from setInterval) to be cancelled when unloading. Use window.setInterval instead of setInterval to avoid TypeScript confusing between NodeJS vs Browser API
(Inherited from MarkdownRenderChild)
registerScopeEvent(keymapEventHandler) void Register a scope keymap event handler to be removed on unload.
(Inherited from MarkdownRenderChild)
removeChild(component) T Removes a child component, unloading it.
(Inherited from MarkdownRenderChild)
render(app, markdown, el, sourcePath, component) Promise<void> Renders Markdown string to an HTML element.
renderMarkdown(markdown, el, sourcePath, component) Promise<void> Renders Markdown string to an HTML element.
resolveLinks(e) unknown Resolve internal links in the rendered markdown.
unload() void Override this to unload your component.
(Inherited from MarkdownRenderChild)

Links to this page: