createFragmentWithCodeBlocks
Builds a DocumentFragment from an already-translated message, rendering every value that was wrapped in asCodeBlock as an inline code block and the rest as plain text.
The message stays ONE translatable unit. Splitting a sentence into a prefix and a suffix around the value is the obvious alternative and it does not survive translation: a language that reorders the clause, or that needs different case on the surrounding words, cannot express that through two fixed halves. Here the value sits wherever the translation puts it, and only its rendering is decided.
A message with nothing marked comes back as plain text, so this is safe to apply to any message.
Import:
import { createFragmentWithCodeBlocks } from 'obsidian-dev-utils/obsidian/html-element';Signature:
function createFragmentWithCodeBlocks(message: string): DocumentFragmentParameters:
| Parameter | Type | Description |
|---|---|---|
message | string | The translated message, with its code values wrapped by asCodeBlock. |
Returns: DocumentFragment — The fragment.
Links to this page: