Skip to content

Commit a970aad

Browse files
committed
Refactor readme.md
1 parent c9451f2 commit a970aad

File tree

1 file changed

+52
-24
lines changed

1 file changed

+52
-24
lines changed

README.md

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,70 @@
1-
# hast-util-to-mdast
1+
# hast-util-to-mdast [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
22

3-
Convert [HAST trees](https://github.com/syntax-tree/hast) to [MDAST trees](https://github.com/syntax-tree/mdast).
3+
Transform [HAST][] (HTML) to [MDAST][] (markdown).
44

5-
## About
5+
> :warn: Work in progress :warn
6+
> See [GH-3][3] for progress.
67
7-
Based on the code in [mdast-util-to-hast](https://github.com/wooorm/mdast-util-to-hast), this module provides a way to transform an HTML abstract syntax tree into a markdown abstract syntax tree.
8+
## Installation
89

9-
Used with [rehype](https://npmjs.com/rehype) and [remark](https://npmjs.com/remark), this allows you to convert HTML into markdown.
10+
[npm][]:
1011

11-
### Work in progress
12+
```bash
13+
npm install hast-util-to-mdast
14+
```
1215

13-
So far this only transforms a few HTML elements, and there's more work to do. To see what's been completed so far look at [the handlers directory](/handlers).
16+
## Usage
1417

15-
## Install
18+
```javascript
19+
var rehype = require('rehype');
20+
var remark = require('remark');
21+
var toMDAST = require('hast-util-to-mdast');
1622

17-
```sh
18-
npm install --save hast-util-to-mdast
23+
var hast = rehype().parse('<h2>Hello <strong>world!</strong></h2>');
24+
var doc = remark().stringify(toMDAST(hast));
25+
console.log(doc);
1926
```
2027

21-
## Usage
28+
Yields:
2229

23-
```js
24-
var unified = require('unified')
25-
var parse = require('rehype-parse')
26-
var stringify = require('remark-stringify')
30+
```txt
31+
## Hello **world!**
32+
```
2733

28-
var toMDAST = require('hast-util-to-mdast')
34+
## API
2935

30-
var result = unified()
31-
.use(parse)
32-
.use(function () { return toMDAST })
33-
.use(stringify)
34-
.process(html, { fragment: true })
36+
### `toMDAST(node)`
3537

36-
console.log(result.contents)
37-
```
38+
Transform the given [HAST][] tree to an [MDAST][] tree.
3839

40+
## Related
41+
42+
* [`mdast-util-to-hast`][mdast-util-to-hast]
3943

4044
## License
4145

42-
[MIT](LICENSE.md)
46+
[MIT][license] © [Titus Wormer][author]
47+
48+
<!-- Definitions -->
49+
50+
[travis-badge]: https://img.shields.io/travis/syntax-tree/hast-util-to-mdast.svg
51+
52+
[travis]: https://travis-ci.org/syntax-tree/hast-util-to-mdast
53+
54+
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-mdast.svg
55+
56+
[codecov]: https://codecov.io/github/syntax-tree/hast-util-to-mdast
57+
58+
[npm]: https://docs.npmjs.com/cli/install
59+
60+
[license]: LICENSE
61+
62+
[author]: http://wooorm.com
63+
64+
[mdast]: https://github.com/syntax-tree/mdast
65+
66+
[hast]: https://github.com/syntax-tree/hast
67+
68+
[mdast-util-to-hast]: https://github.com/syntax-tree/mdast-util-to-hast
69+
70+
[3]: https://github.com/syntax-tree/hast-util-to-mdast/issues/3

0 commit comments

Comments
 (0)