1.1.3 • Published 4 years ago
escape-html-tags v1.1.3
Escape Html Tags
Escape html tags to insert html into html code
escapeHtmlTags(input) ⇒ string
Escape special characters in the given string of text. This function will escape the following characters: ", ', &, <, and >.
Kind: global function
Param | Type | Description |
---|---|---|
input | string | The string to escape for inserting into HTML |
The escapeHtml function is designed to accept a string input of text and return an escaped value.
const escapeHtml = require('escape-html')
// example values
const str = 'Escaping <i>html</i> works fine.'
// example passing text in span element
console.log('<span name="desc">' + escapeHtml(str) + '</span>')
// -> '<span name="desc">Escaping <i>html</i> works fine.</span>'