formatCodeBlock
Formats a code block from its fields and their values.
Each field holding a value other than its default, or marked CodeBlockBuilderFieldBase.isRequired, writes one line, in the order of the fields; an empty value writes nothing. The fence is one backtick longer than the longest backtick run in the lines, and never shorter than three.
Import:
import { formatCodeBlock } from '@mnaoumov/obsidian-lib/modals/code-block-builder';Signature:
function formatCodeBlock(params: FormatCodeBlockParams): stringParameters:
| Parameter | Type | Description |
|---|---|---|
params |
FormatCodeBlockParams | The fields, the language and the values. |
Returns: string — The code block, without a trailing newline.
Links to this page: