Skip to main content

@rtorcato/js-common / html

html

Functions

escapeHtml()

escapeHtml(str): string

Defined in: html/index.ts:6

Escapes special HTML characters in a string to prevent XSS attacks.

Parameters

str

string

The string to escape.

Returns

string

The escaped string.


unescapeHtml()

unescapeHtml(str): string

Defined in: html/index.ts:20

Unescapes HTML entities in a string.

Parameters

str

string

The string to unescape.

Returns

string

The unescaped string.


stripHtmlTags()

stripHtmlTags(str): string

Defined in: html/index.ts:34

Strips all HTML tags from a string.

Parameters

str

string

The string to strip tags from.

Returns

string

The plain text string.


textToHtml()

textToHtml(str): string

Defined in: html/index.ts:43

Converts a plain text string to a simple HTML paragraph (newlines become <br> tags).

Parameters

str

string

The plain text string.

Returns

string

The HTML string with <br> tags.


containsHtml()

containsHtml(str): boolean

Defined in: html/index.ts:52

Checks if a string contains any HTML tags.

Parameters

str

string

The string to check.

Returns

boolean

True if the string contains HTML tags, false otherwise.