Skip to content

Commit bbec0f7

Browse files
committed
Add README
1 parent 45df9c6 commit bbec0f7

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#jsonml-parse
2+
3+
Convert markup (HTML) in text form to [JSONML](http://jsonml.org).
4+
5+
[![Travis CI Build Status](https://travis-ci.org/CMTegner/jsonml-parse.svg)](http://travis-ci.org/CMTegner/jsonml-parse) [![Dependency Status](https://david-dm.org/CMTegner/jsonml-parse/status.svg)](https://david-dm.org/CMTegner/jsonml-parse) [![NPM Module Version](https://badge.fury.io/js/jsonml-parse.svg)](https://npm.im/jsonml-parse)
6+
7+
[![Browser support](https://ci.testling.com/CMTegner/jsonml-parse.png)](https://ci.testling.com/CMTegner/jsonml-parse)
8+
9+
##Example
10+
11+
```js
12+
var parse = require('jsonml-parse');
13+
parse('<button class="btn">Awesome</button>', function(err, data) {
14+
console.dir(data);
15+
//-> ["button", { "class": "btn" }, "Awesome"]
16+
});
17+
```
18+
19+
## Install
20+
21+
With [npm](http://npmjs.org) do:
22+
```bash
23+
npm install jsonml-parse
24+
```
25+
26+
## Usage
27+
28+
```javascript
29+
var parse = require('jsonml-parse');
30+
```
31+
32+
`jsonml-parse` exposed two different API styles: callback and stream.
33+
34+
### parse(markup, callback)
35+
36+
Parses the `markup` string and invokes `callback` when done. `callback` is treated as a node-style callback, i.e. the first argument will always be the error object (`null` on success), and the second will always be the JSONML result. *Note:* If `markup` contains multiple top-level nodes they will be wrapped in an array before being passed to `callback`.
37+
38+
### var stream = parse()
39+
40+
Returns a new [transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform) which you will write the markup to, and read the JSONML from. *Note:* Each top-level node will be emitted as separate 'data' events.
41+
42+
## CLI
43+
44+
`jsonml-parse` also comes with a CLI tool (`jsonmlparse`):
45+
46+
```bash
47+
$ jsonmlparse --help
48+
49+
Usage: node jsonmlparse [file] [options]
50+
51+
file The file containing the markup to convert to JSONML, will read from stdin if not specified
52+
53+
Options:
54+
-o, --output Output file, will send to stdout if not specified
55+
--version Print version and exit
56+
```
57+
58+
Example:
59+
60+
```bash
61+
curl www.bbc.co.uk | jsonmlparse > bbc.json
62+
```

0 commit comments

Comments
 (0)