Search code examples
sgmlreader

How to stop SGMLReader to add missing tags like <html> in output


I'm using SGML Reader to format my html snippets as shown here https://github.com/MindTouch/SGMLReader. Problem is it adds missing tags like in the code. Is there is any way to stop that.


Solution

  • SgmlReader is intended to convert the source into a valid HTML document. Hence, it will always surround the parsed content with . If you want to remove some of the tags, you can traverse the XML document and either remove the nodes you don't want or, alternatively, copy only the nodes you want to a new XML document.