Skip to content

markdown-code-block-processor

This module provides utility functions for processing code blocks in Obsidian.

Interface Description
GetCodeBlockMarkdownInfoParams Options for getCodeBlockMarkdownInfo.
InsertCodeBlockParams Options for insertAfterCodeBlock / insertBeforeCodeBlock.
RemoveCodeBlockParams Options for removeCodeBlock.
ReplaceCodeBlockParams Options for replaceCodeBlock.
Function Description
getCodeBlockMarkdownInfo Gets the information about a code block in a Markdown section. This is a pure read, safe to call while a code block renders. It locates the block in the text the user sees: the view data of an open markdown view of the source note when there is one, because an unsaved edit there is what the block was rendered from, and the file’s content otherwise. It never saves the note.
insertAfterCodeBlock Inserts text after the code block.
insertBeforeCodeBlock Inserts text before the code block.
removeCodeBlock Removes the code block.
replaceCodeBlock Replaces the code block.