Still working on this. Got as far as the body tag and into the header of the page I'm working on. But, surprise, the HTML is malformed. They failed to close an element. So I had to add a rule so that, if an ancestor element is closed, it treats that as implicitly closing the current element.
@madewokherd the train of thought is, first it's just html, but someday you're probably going to find some website that needs to fetch the content with javascript, so maybe it does make sense to reuse all the browser crap but wrap it in a highly controlled layer. but that does make it a very different kind of project