escape
Escapes all Markdown special characters in a string so they render as literal text rather than formatting syntax.
Escaped characters: \ \ * _ { } [ ] ( ) # + - . !`
Pass { cell: true } to also escape pipe characters and replace newlines
with spaces, making the result safe for embedding in a Markdown table cell.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
str | string | The raw string to escape |
options | EscapeOptions | Optional escaping options (optional) |
Returns
Section titled “Returns”string — The escaped string
Examples
Section titled “Examples”Escape special Markdown characters
Section titled “Escape special Markdown characters”Prefixes every Markdown special character with a backslash.
Safely render user input inside Markdown
Section titled “Safely render user input inside Markdown”Prevents user-supplied strings from breaking Markdown formatting.
Related Types
Section titled “Related Types”EscapeOptions
Section titled “EscapeOptions”Options for escape.
