Socket
Socket
Sign inDemoInstall

innertext

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    innertext

Extract the innerText from a snippet of HTML


Version published
Maintainers
1
Install size
74.3 kB
Created

Readme

Source

innertext

Extract the innerText from a snippet of HTML

Greenkeeper badge Build Status Code Climate

Installation

npm install innertext

Usage

Pass it a string containing some HTML.

var innertext = require('innertext');

var text = innertext('<h1>Heading text <em>with</em> <b>some</b> <u>markup</u></h1>');

console.log(text); // 'Heading text with some markup'

Correctness

The current implementation favors speed and simplicity over other considerations like perfect web browser compatibility. For instance:

  • malformed HTML (e.g., un-encoded < & > characters, etc…) will generally break the text extraction process
  • whitespace around HTML tag/element boundaries gets collapsed into a single space, whereas browsers will typically preserve newlines

So if you trust the incoming HTML, things will typically be OK, but don't use this as the basis for creating a browser or anything.

Tests

npm install
npm test

License

ISC

Keywords

FAQs

Last updated on 06 Mar 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc