Skip to content

appendCodeBlock

Appends a code block to the given DocumentFragment or HTMLElement, styled to match Obsidian’s rendered-markdown inline code.

Import:

import { appendCodeBlock } from 'obsidian-dev-utils/obsidian/html-element';

Signature:

function appendCodeBlock(el: HTMLElement | DocumentFragment, code: string): void

Parameters:

ParameterTypeDescription
elHTMLElement | DocumentFragmentThe DocumentFragment or HTMLElement to append the code block to.
codestringThe code to be displayed in the code block.

Returns: void