Skip to content

escapeSvgText

Escapes text for inclusion in SVG character data.

A caption is authored per screenshot and can legitimately contain & or the angle brackets Obsidian uses in link syntax; unescaped, those make the SVG impossible to parse and sharp fails on a caption rather than on an image.

Import:

import { escapeSvgText } from 'obsidian-integration-testing';

Signature:

function escapeSvgText(text: string): string

Parameters:

ParameterTypeDescription
textstringThe raw caption.

Returns: string — The caption, safe to embed in SVG.