Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

prune-html

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prune-html

Given an html string it removes elements matching CSS selector(s) and returns the pruned html string.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
6
-25%
Maintainers
1
Weekly downloads
 
Created
Source

prune-html build status

Given an html string it removes elements matching CSS selector(s) and returns the pruned html string.

var pruneHtml = require('prune-html');

var html = [
    '<div>'
  , '  <h1 class="page-title">Global</h1>'
  , '  <header>'
  , '    <h2>Hello</h2>'
  , '  </header>'
  , '  <article>'
  , '    <div class="container-overview">'
  , '      <dl class="details"></dl>'
  , '    </div>'
  , '    <h3 class="subsection-title">Methods</h3>'
  , '  </article>'
  , '</div>'
].join('\n')

console.log(pruneHtml([ 'h1', '.details', 'h3' ], html));
/* =>
<div>
  <header>
    <h2>Hello</h2>
  </header>
  <article>
    <div class="container-overview">
    </div>
  </article>
</div> */

Installation

npm install prune-html

API

pruneHtml(selectors, html)

/**
 * Prunes all elements matching the selectors from the given html and returns result.
 * 
 * @name pruneHtml
 * @function
 * @param {Array.<String>|String} selectors if one of these CSS selector(s) matches, the element is pruned
 * @param {String} html unpruned
 * @return {String} the pruned html
 */

License

MIT

Keywords

prune

FAQs

Package last updated on 16 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts