Skip to content

Instantly share code, notes, and snippets.

@aredridel
Created May 24, 2010 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aredridel/412074 to your computer and use it in GitHub Desktop.
Save aredridel/412074 to your computer and use it in GitHub Desktop.
Proposed API for HTML5 parser in Javascript
var HTML5 = require('html5')
HTML5.parse(string, [{DOM: domModule}]) -> DOM objects
new HTML5.Parser(source, [{DOM: domModule}]) -> eventEmitter with "document" property. emits "end" when fully parsed, and the document property is a DOM tree
Internal:
new HTML5.Tokenizer(source) -> eventEmitter that emits 'token' for each token and 'end' when done. This isn't useful outside the parser since the tokenizer needs feedback from the parser.
The Tokenizer has a "state" property that is the name of the function to call for the current tokenizer state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment