logo

/Code Snippet|v2.3.3

Module

Static Methods

decodeHTMLEntity(htmlEntity)decodeHTMLEntity.jsline 26

Transform the given HTML Entity string into plain string.

PARAMETERS
NameTypeDescription

htmlEntity

String

HTML Entity type string

RETURNS:
{

String

} - Plain string
EXAMPLES
// ES6
import decodeHTMLEntity from 'tui-code-snippet/string/decodeHTMLEntity';

// CommonJS
const decodeHTMLEntity = require('tui-code-snippet/string/decodeHTMLEntity');

const htmlEntityString = "A 'quote' is <b>bold</b>"
const result = decodeHTMLEntity(htmlEntityString); //"A 'quote' is <b>bold</b>"

encodeHTMLEntity(html)encodeHTMLEntity.jsline 22

Transform the given string into HTML Entity string.

PARAMETERS
NameTypeDescription

html

String

String for encoding

RETURNS:
{

String

} - HTML Entity
EXAMPLES
// ES6
import encodeHTMLEntity from 'tui-code-snippet/string/encodeHTMLEntity';

// CommonJS
const encodeHTMLEntity = require('tui-code-snippet/string/encodeHTMLEntity');

const htmlEntityString = "<script> alert('test');</script><a href='test'>";
const result = encodeHTMLEntity(htmlEntityString);
Resizable