Over the weekend and in some spare time during the past few days I've been implementing an HTML5 tokenizer. (Based on work from James Graham.) The tokenizer here tells a potential tree constructor when a new start tag is found and what the attributes of that tag are. It also gives you a notification when it encounters a doctype, comment, et cetera. Pretty cool stuff. The project is called html5lib and you’re free to contribute.
Also note that HTML5 does not give you another way of parsing HTML. It in fact defines a way of parsing documents that is compatible with as much documents out there while remaining compatible with the DOM specifications.
It should be noted that there is also some (less finished, but partially functional) work on implementing the parser/treebuilder itself. At present the parser constructs a custom tree format that's based on the minimal amount of DOM core needed to test the parser code. Longer term the goal is to abstract out the treebuilding so treebuilders can be implemented for e.g. elementtree, XML.minidom and, perhaps, event-based models like SAX (this latter one is harder though because the HTML5 parser spec requires elements to be moved around after they have been created, so some tree-like buffering is needed with events only being emitted after there is no possibility of the subtree changing).
Hi Anne, Added your code to the list of other parsers.
Good news!
Two questions: