Skip to content

Commit

Permalink
Fix README example
Browse files Browse the repository at this point in the history
  • Loading branch information
aredridel committed Aug 9, 2014
1 parent 6e5c61c commit 4ba1fcf
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,26 @@ HTML5 Parser for node.js

[![Build Status](https://travis-ci.org/aredridel/html5.svg?branch=master)](https://travis-ci.org/aredridel/html5)

Example (With jQuery!)
----------------------
```js
/* Before you run this, run:
(cd deps/jquery; rake)
*/
var HTML5 = require('html5'),
Script = process.binding('evals').Script,
util = require('util'),
fs = require('fs'),
jsdom = require('jsdom'),
window = jsdom.jsdom(null, null, {parser: HTML5}).createWindow()

var parser = new HTML5.Parser({document: window.document});

var inputfile = fs.readFileSync('doc/jquery-example.html');
parser.parse(inputfile);

jsdom.jQueryify(window, __dirname + '/deps/jquery/dist/jquery.js', function(window, jquery) {
Script.runInNewContext('jQuery("p").append("<b>Hi!</b>")', window);
util.puts(window.document.innerHTML);

});
Examples
--------

A simple example:

```javascript
var HTML5 = require('html5');
var jsdom = require('jsdom');
var core = jsdom.browserAugmentation(jsdom.level(3));

var impl = new core.DOMImplementation();
var document = impl.createDocument();
var parser = new HTML5.JSDOMParser(document, core);

parser.parse('<p>I am a very small HTML document</p>');

console.log(document.getElementsByTagName("p")[0].innerHTML);
```


Interesting features
--------------------

Expand All @@ -50,6 +46,4 @@ and give it a run:

npm test

(At time of this writing, 1800 tests pass)

Git repository at http://dinhe.net/~aredridel/projects/js/html5.git/

0 comments on commit 4ba1fcf

Please sign in to comment.