npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-html-plain-parser

v1.0.7

Published

Based on react-xml-parser which used for xml parser. Aiming to parse HTML using regex, offer some convinent functions with no mercy on effeciency.

Downloads

4

Readme

Obviously there are too many great solutions but not this.

react-html-plain-parser

Based on react-xml-parser which used for xml parser. Aiming to parse HTML using regex, offer some convinent functions with no mercy on effeciency.

Installation

$ npm install react-html-plain-parser

Usage

Basic

// const parser = require('react-html-plain-parser')
import parser from 'react-html-plain-parser'

const htmlString = `<div>2333</div>`
const parser = new HTMLParser()
const rootNode = parser.parseFromString(htmlString) // get root node from plain html
const arr = rootNode.getElementsByTagName('div') // get all div tags, find from rootNode 

const beautifiedText = parser.textBeautify(parser.toString(arr[0]))

Selector

  • FilterType: TAG, ATTR, CLASS, ID, VALUE
  • FilterOpt: INCLUDE, EQUAL, START_WITH, END_WITH, NOT_INCLUDE, NOT_EQUAL, NOT_START_WITH, NOT_END_WITH
  • OutputType: NODE, TAG, ATTR, VALUE, CHILDREN
const {FilterType, FilterOpt, OutputType, filterConfig, outputConfig, select} = parser
const configs = [
    filterConfig(FilterType.TAG, FilterOpt.START_WITH, 'd'),
    filterConfig(FilterType.ATTR, FilterOpt.NOT_EQUAL, ['display', 'none']),
    filterConfig(FilterType.CLASS, FilterOpt.END_WITH, 't'),
    filterConfig(FilterType.ID, FilterOpt.INCLUDE, 'not')
]
const output = outputConfig(OutputType.TAG)
const res = select(html, configs, output)

const config = filterConfig(FilterType.TAG, FilterOpt.EQUAL, 'a')
const res2 = select(html, config, outputConfig(OutputType.ATTR, 'href'))

Update

  • v1.0.7 fix NOT selector incorrect result
  • v1.0.6 fix config return, bind this, fix NOT selector incorrect result, clean dependencies, make more bugs.
  • v1.0.5 read enum fixing (deadly bugs, unable to run)
  • v1.0.4 - (deadly bugs, unable to run)
  • v1.0.3 the biggest update ever, offer selector with terrible effeciency. (deadly bugs, unable to run)
  • v1.0.2 add html text beautify

Based on react-xml-parser

https://github.com/matanshiloah/xml-parser/

License

ISC