# @starptech/rehype-webparser

> Parses HTML via [**Webparser**](https://github.com/Prettyhtml/prettyhtml/tree/master/packages/webparser) to a [**HAST**](https://github.com/syntax-tree/hast) syntax tree.

Latest version **0.10.0** (published 2019-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @starptech/rehype-webparser
pnpm add @starptech/rehype-webparser
yarn add @starptech/rehype-webparser
bun add @starptech/rehype-webparser
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.0 |
| Published | 2019-06-21 |
| First published | 2018-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Dustin Deus |
| Maintainers | starptech |
| Keywords | webparser, parser, rehype |

## Links

- npm: https://www.npmjs.com/package/@starptech/rehype-webparser
- npm.io page: https://npm.io/package/@starptech/rehype-webparser

## Dependencies (2)

- [@starptech/webparser](https://npm.io/package/@starptech/webparser.md) ^0.10.0
- [@starptech/hast-util-from-webparser](https://npm.io/package/@starptech/hast-util-from-webparser.md) ^0.10.0

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

- 0.10.0 (latest) — 2019-06-21
- 0.9.0 — 2019-04-28
- 0.8.17 — 2019-04-07
- 0.8.10 — 2018-12-09
- 0.8.7 — 2018-12-06
- 0.8.6 — 2018-12-04
- 0.8.5 — 2018-11-28
- 0.8.3 — 2018-11-24
- 0.8.1 — 2018-11-12
- 0.8.0 — 2018-11-11
- 0.7.0 — 2018-11-10
- 0.6.0 — 2018-11-08
- 0.5.3 — 2018-11-08
- 0.5.2 — 2018-11-06
- 0.5.0 — 2018-10-28
- … 17 more at https://npm.io/package/@starptech/rehype-webparser/versions

## README

# @starptech/rehype-webparser

Parses HTML via [**Webparser**](https://github.com/Prettyhtml/prettyhtml/tree/master/packages/webparser) to a [**HAST**](https://github.com/syntax-tree/hast) syntax tree.

## Installation

```
npm install --save @starptech/rehype-webparser
```

## Usage

This example shows how we parse HTML with [**Webparser**](https://github.com/Prettyhtml/prettyhtml/blob/master/packages/webparser) transform it into [**HAST**](https://github.com/syntax-tree/hast) compatible structure and finally compile that data back to HTML with [hast-util-to-html](https://github.com/syntax-tree/hast-util-to-html).

Say we have the following file, `example.html`:

```html
<!DOCTYPE html>
<title>Hello!</title>
<h1 id="world">World!</h1>
```

And our script, `example.js`, looks as follows:

```javascript
const vfile = require('to-vfile')
const report = require('vfile-reporter')
const unified = require('unified')
const parse = require('@starptech/rehype-webparser')
const toHTML = require('hast-util-to-html')

// A compiler is needed to inform unified how to transform it back to HTML
function stringify() {
  this.Compiler = compiler

  function compiler(tree) {
    return toHTML(tree)
  }
}

unified()
  .use(parse)
  //.use(yourPlugin)
  .use(stringify)
  .process(vfile.readSync('example.html'), function(err, file) {
    console.error(report(err || file))
    console.log(String(file))
  })
```

Now, running `node example` yields:

```text
<!doctype html>
<title>Hello!</title>
<h1 id="world">World!</h1>
```

## API

### `processor.use(webparser[, options])`

Configure the `processor` to read HTML as input and process a
[**HAST**](https://github.com/syntax-tree/hast) syntax tree.

###### `options.*`

[**Webparser**](https://github.com/Prettyhtml/prettyhtml/blob/master/packages/webparser) options.

---
_Source: https://npm.io/package/@starptech/rehype-webparser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
