Skip to content

rerenderPreviews

Renders the open Reading views again, so a markdown post-processor or code block processor registered or reconfigured since they rendered applies to them.

It covers every Markdown view in every window, popouts included. A full refresh is what Obsidian itself does when a post-processor is registered: every section is rendered again, except the header holding the inline title and the properties, and the footer holding the backlinks, which keep their DOM. With a language, only the sections holding a code block of that language are rendered again. The note is never written, the view mode never changes, and the scroll position is kept by Obsidian’s renderer.

The promise settles once every view SHOWN in Reading view has finished rendering, the promises of asynchronous post-processors included. A preview that is not shown (a background tab, a view in editing mode) is marked to render again when it is next shown, and is not waited for, since Obsidian does not render it until then. A view that is closed, hidden or switched out of Reading view while rendering stops being waited for. A post-processor whose promise never settles, or rejects, keeps its view’s render open, exactly as it keeps Obsidian’s own render open; pass an abortSignal to bound the wait.

Hover popovers, embeds, canvas cards and Live Preview widgets are not refreshed.

Import:

import { rerenderPreviews } from '@mnaoumov/obsidian-lib/markdown-view';

Signature:

function rerenderPreviews(params: RerenderPreviewsParams): Promise<void>

Parameters:

Parameter Type Description
params RerenderPreviewsParams The options.

Returns: Promise<void> — A promise that resolves once the shown Reading views have rendered.


Links to this page: