polyglottify

github godoc cli loading
polyglottify converts an HTML document to polyglot markup: well-formed XML (XHTML) which is parsed the same way by browsers and XML parsers whether it is served as text/html or application/xhtml+xml. The differences between the input and output are highlighted, and anything which can't be represented in both formats results in a warning in the bottom panel. The conversion is run locally in your browser without uploading it to any remote servers.

The output mostly follows the format described by the W3C Polyglot Markup note, with a few changes to improve compatibility with modern browsers. In addition, the source document is parsed and normalized mostly according to the HTML specification, with some changes to allow it to work in a single streaming pass, and be more robust against untrusted input. It handles malformed input (like unclosed tags) more or less the same way as browsers.

This is a demo of the polyglot package of github.com/pgaskin/htmlstream, a Go library for streaming parsing and transformation of HTML, XHTML and XML which passes input through byte for byte unless modified, tolerates malformed input, and uses has bounded resource usage, even on untrusted content.

This tool is also available as a command-line tool.

input
output
Loading the editor and converter...