Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

escape-html-tags

vikas.keskar11MIT1.1.3

Escape string having html tags for use in HTML

escape, html, tags, escape html, utility

readme

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 &lt;i&gt;html&lt;/i&gt; works fine.</span>'