cleanse-html

0.0.5 • Public • Published

cleanse-html

Simple tool to remove html from a string and returns a string of plain text

Installation

npm install cleanse-html

Simple Examples

var cleanse = require('cleanse-html');
var html = '<p>Hello World</p>';
 
console.log(cleanse(html)); // Hello World
 
//To select things you want to keep, pass an options object as the second parameter
//or call configure() with the options object (see below for options)
html = "<head><title>Testing</title></head><p>Hello World</p>";
console.log(cleanse(html,{head:false})); // Testing Hello World
 
cleanse.configure({head:true,html:false});
console.log(cleanse(html)); // <p>Hello World</p>

API

Create instance

var cleanse = require('cleanse-html');

Clease text

cleanse(string,options);
  • string is the text that you want to cleanse.
  • options is an optional settings object describing what to cleanse:
    • entity (bool) remove/ignore HTML entities (names and numbers). Defaults to true.
    • head (bool) remove/ignore section. Defaults to true.
    • script (bool) remove/ignore

Readme

Keywords

Package Sidebar

Install

npm i cleanse-html

Weekly Downloads

73

Version

0.0.5

License

none

Last publish

Collaborators

  • dprior