escapeMd

escapeMd, function

def const pure escapeMd(source: text): markdown

Escapes Markdown control characters in source and returns a markdown value that renders as the original, unformatted text.

Examples

raw = "*Not bold* and [not a link](https://example.com/)"
escaped = escapeMd(raw)

show markdown "Escaped Markdown" with escaped

The tile displays the asterisks, brackets, and parentheses literally instead of applying bold or link formatting.

Remarks

escapeMd escapes backslashes and the Markdown control characters `, *, _, {, }, [, ], <, >, (, ), #, +, -, ., !, and |.

Text expressions interpolated directly into a Markdown template are escaped automatically. escapeMd is useful when the escaped result must be stored or passed as an explicit markdown value.

Unlike escape, which produces an Envision text literal, escapeMd returns Markdown ready for display.

Errors

If the escaped representation would exceed 256 UTF-8 bytes, escapeMd fails with an error such as:

escapeMd(): “…” escapes to more than 256 UTF-8 bytes.

See also

User Contributed Notes
0 notes + add a note