# tag-name-parser

> A tag parser that does not support attributes. Lightweight and fast.

Latest version **1.0.1** (published 2019-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install tag-name-parser
pnpm add tag-name-parser
yarn add tag-name-parser
bun add tag-name-parser
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-04-16 |
| First published | 2018-12-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | skt-t1-byungi |
| Maintainers | skt-t1-byungi |
| Keywords | tag, html, dom, xml, tag name, parser, parse |

## Links

- npm: https://www.npmjs.com/package/tag-name-parser
- Repository: https://github.com/skt-t1-byungi/tag-name-parser
- npm.io page: https://npm.io/package/tag-name-parser

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-04-16
- 1.0.0 — 2019-04-16
- 0.2.2 — 2018-12-15
- 0.2.1 — 2018-12-15
- 0.2.0 — 2018-12-15
- 0.1.1 — 2018-12-14
- 0.1.0 — 2018-12-14
- 0.0.2 — 2018-12-13
- 0.0.1 — 2018-12-13

## README

# tag-name-parser
A tag parser that does not support attributes. Lightweight and fast.

[![npm](https://flat.badgen.net/npm/v/tag-name-parser)](https://www.npmjs.com/package/tag-name-parser)

## Install
```sh
npm i tag-name-parser
```

## Usage
```js
const parse = require('tag-name-parser')

parse(`hello <a>world<b>~</b><c/>!</a>`)
```
output:
```js
[
    'hello ',
    {
        name: 'a',
        single: false,
        children: [
            'world',
            {
                name: 'b',
                single: false,
                children: [
                    '~'
                ]
            },
            {
                name: 'c',
                single: true
            },
            '!'
        ]
    }
]
```

## Non-strict mode
If strict is false, the result is returned without error.

```js
parse('<a>invalid<b>', {strict: false})
```
output:
```js
[
    {
        name: 'a',
        single: false,
        children: [
            'invalid',
            {
                name: 'b',
                single: false,
                children: []
            }
        ]
    }
]
```

## Change tag brackets.
```js
parse('hello [a]world[/a]', {tag: ['[', ']']})
```
output:
```js
{
    'hello ',
    {
        name: 'a',
        single: false,
        children: [
            'world'
        ]
    }
}
```

## Benchmark
Each test 10,000 times. (bench-example.txt)

tag-name-parser|htmlparser2|parse5|sax|html-parse-stringify2|fast-xml-parser
---|---|---|---|---|---
**~184 ms**|~609 ms|~2.67 s|~1.41 s|~910 ms|~529 ms

> It is fast because it does not provide much. 😜

## License
MIT

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