Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decode-entities-from-text

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decode-entities-from-text

If you work with apis (particularly ones that give back html), you'll eventually see something like `–` show up where a `-` should be.

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Decode entities from text (Works with node)

If you work with apis (particularly ones that give back html), you'll eventually see something like – show up where a - should be.

These are html entities. This function parses them out and converts them to what you'd expect to see.

Parsing these out is particularly challenging when working with Nodejs or a build tool like Gatsby.

It's perfect for those Gatsby sites that consume content via a Wordpress api or something. But, build the html in nodejs where you don't have access to the standard html document.

To see a complete list of HTML entities, see here.

To Use

import decodeEntities from 'decode-entities-from-text';

function MyTitle(props) {
  const { possiblyDirtyString } = props;
  const title = decodeEntities(possiblyDirtyString);

  return <h1>{title}</h1>;
}

FAQs

Package last updated on 09 Oct 2019

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc