Permalink
Browse files

added text callbacks to parse example

  • Loading branch information...
1 parent 6f7e02e commit e5ae4890790ece29276b3ced04b4c3f24bc3e477 @tmont committed Feb 10, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 README.md
View
7 README.md
@@ -19,15 +19,16 @@ parse as if it were valid XML.
```javascript
var htmlParser = require('html-parser');
-var html = '<!doctype html><html><body onload="alert(\'hello\');">Yo<br />dawg</body></html>';
+var html = '<!doctype html><html><body onload="alert(\'hello\');">Hello<br />world</body></html>';
htmlParser.parse(html, {
openElement: function(name) { console.log('open: %s', name); },
closeOpenedElement: function(name, token) { console.log('close token: %s', token); },
closeElement: function(name) { console.log('close: %s', name); },
comment: function(value) { console.log('comment: %s', value); },
cdata: function(value) { console.log('cdata: %s', value); },
attribute: function(name, value) { console.log('attribute: %s=%s', name, value); },
- docType: function(value) { console.log('doctype: %s', value); }
+ docType: function(value) { console.log('doctype: %s', value); },
+ text: function(value) { console.log('text: %s', value); }
});
/*
@@ -37,8 +38,10 @@ close token: >
open: body
attribute: onload=alert('hello');
close token: >
+text: Hello
open: br
close token: />
+text: world
close: body
close: html
*/

0 comments on commit e5ae489

Please sign in to comment.