# 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.

Latest version **1.0.7** (published 2019-04-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-html-plain-parser
pnpm add react-html-plain-parser
yarn add react-html-plain-parser
bun add react-html-plain-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2019-04-16 |
| First published | 2019-04-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 271 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | strk2333 |
| Maintainers | strk2333 |
| Keywords | HTML, react, selector |

## Links

- npm: https://www.npmjs.com/package/react-html-plain-parser
- Repository: https://github.com/strk2333/html-plain-parser
- Homepage: https://github.com/strk2333/html-plain-parser#readme
- Issues: https://github.com/strk2333/html-plain-parser/issues
- npm.io page: https://npm.io/package/react-html-plain-parser

## Dependencies (8)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.5
- [babel-core](https://npm.io/package/babel-core.md) ^6.26.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.3.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.2.2
- [html-loader](https://npm.io/package/html-loader.md) ^0.5.5
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.2.3
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.24.1

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2019-04-16
- 1.0.6 — 2019-04-16
- 1.0.5 — 2019-04-16
- 1.0.4 — 2019-04-15
- 1.0.3 — 2019-04-15
- 1.0.2 — 2019-04-11
- 1.0.1 — 2019-04-10
- 1.0.0 — 2019-04-10

## 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

---
_Source: https://npm.io/package/react-html-plain-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
