Factor out the serialization algorithm for DocumentType nodes, and use it for HTML.

There are no changes in the algorithm.