1 | # rehype [![Build Status][build-badge]][build-status] [![Coverage Status][coverage-badge]][coverage-status] [![Chat][chat-badge]][chat]
|
2 |
|
3 | The [**rehype**][rehype] processor is an HTML processor powered by
|
4 | [plug-ins][plugins].
|
5 |
|
6 | * Interface by [**unified**][unified];
|
7 | * [**hast**][hast] syntax tree;
|
8 | * Parses HTML to the tree with [**rehype-parse**][parse];
|
9 | * [Plug-ins][plugins] transform the tree;
|
10 | * Compiles the tree to HTML using [**rehype-stringify**][stringify].
|
11 |
|
12 | Don’t need the parser? Or the compiler? [That’s OK][unified-usage].
|
13 |
|
14 | ## Installation
|
15 |
|
16 | [npm][]:
|
17 |
|
18 | ```bash
|
19 | npm install rehype
|
20 | ```
|
21 |
|
22 | ## Usage
|
23 |
|
24 | ```js
|
25 | var rehype = require('rehype');
|
26 | var report = require('vfile-reporter');
|
27 |
|
28 | rehype().process('<title>Hi</title><h2>Hello world!', function (err, file) {
|
29 | console.log(report(err || file));
|
30 | console.log(String(file));
|
31 | });
|
32 | ```
|
33 |
|
34 | Yields:
|
35 |
|
36 | ```txt
|
37 | no issues found
|
38 | <html><head><title>Hi</title></head><body><h2>Hello world!</h2></body></html>
|
39 | ```
|
40 |
|
41 | Configuration for [**rehype-parse**][parse] and
|
42 | [**rehype-stringify**][stringify] can be given as an object between the
|
43 | document and the callback.
|
44 |
|
45 | ## License
|
46 |
|
47 | [MIT][license] © [Titus Wormer][author]
|
48 |
|
49 |
|
50 |
|
51 | [build-badge]: https://img.shields.io/travis/wooorm/rehype.svg
|
52 |
|
53 | [build-status]: https://travis-ci.org/wooorm/rehype
|
54 |
|
55 | [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/rehype.svg
|
56 |
|
57 | [coverage-status]: https://codecov.io/github/wooorm/rehype
|
58 |
|
59 | [chat-badge]: https://img.shields.io/gitter/room/wooorm/rehype.svg
|
60 |
|
61 | [chat]: https://gitter.im/wooorm/rehype
|
62 |
|
63 | [license]: https://github.com/wooorm/rehype/blob/master/LICENSE
|
64 |
|
65 | [author]: http://wooorm.com
|
66 |
|
67 | [npm]: https://docs.npmjs.com/cli/install
|
68 |
|
69 | [rehype]: https://github.com/wooorm/rehype
|
70 |
|
71 | [unified]: https://github.com/wooorm/unified
|
72 |
|
73 | [hast]: https://github.com/wooorm/hast
|
74 |
|
75 | [parse]: https://github.com/wooorm/rehype/blob/master/packages/rehype-parse
|
76 |
|
77 | [stringify]: https://github.com/wooorm/rehype/blob/master/packages/rehype-stringify
|
78 |
|
79 | [plugins]: https://github.com/wooorm/rehype/blob/master/doc/plugins.md
|
80 |
|
81 | [unified-usage]: https://github.com/wooorm/unified#usage
|