Sanitizes text for safe HTML rendering by escaping potentially dangerous characters while preserving valid HTML tags.
This function performs the following transformations:
LIMITATIONS: This regex-based approach has known limitations:
The sanitized text safe for HTML rendering, or the original value if null/undefined.
sanitizeTextForRender('Hello\nWorld') // 'Hello<br>World'sanitizeTextForRender('if x < 5') // 'if x < 5'sanitizeTextForRender('<div>Hello</div>') // '<div>Hello</div>'sanitizeTextForRender('Price < $100 <strong>Sale!</strong>') // 'Price < $100 <strong>Sale!</strong>'
The text to sanitize. Can be null or undefined.
Generated using TypeDoc
Sanitizes text for safe HTML rendering by escaping potentially dangerous characters while preserving valid HTML tags.
This function performs the following transformations:
)
LIMITATIONS: This regex-based approach has known limitations:
Returns
The sanitized text safe for HTML rendering, or the original value if null/undefined.
Example
Parameters
text: undefined | null | string
The text to sanitize. Can be null or undefined.
Returns string
Settings
Member Visibility
Theme