######################## Parse HTML into a tree ######################## Turn markup into a navigable tree with :func:`turbohtml.parse`: parse a whole document, feed one arriving in chunks, or parse a fragment in a given context. ************************************* Parse a document arriving in chunks ************************************* When a document arrives over a stream you do not have to buffer the whole thing before parsing. Feed each chunk to an :class:`turbohtml.IncrementalParser` and call ``close()`` for the finished :class:`~turbohtml.Document`; the parser holds only the bytes it has not yet consumed, never the whole source, and the result is identical to parsing the joined string with :func:`turbohtml.parse`: .. testcode:: parser = turbohtml.IncrementalParser() for chunk in ("