type writer … // Render renders the parse tree n to the given writer. // // Rendering is done on a 'best effort' basis: calling Parse on the output of // Render will always result in something similar to the original tree, but it // is not necessarily an exact clone unless the original tree was 'well-formed'. // 'Well-formed' is not easily specified; the HTML5 specification is // complicated. // // Calling Parse on arbitrary input typically results in a 'well-formed' parse // tree. However, it is possible for Parse to yield a 'badly-formed' parse tree. // For example, in a 'well-formed' parse tree, no <a> element is a child of // another <a> element: parsing "<a><a>" results in two sibling elements. // Similarly, in a 'well-formed' parse tree, no <a> element is a child of a // <table> element: parsing "<p><table><a>" results in a <p> with two sibling // children; the <a> is reparented to the <table>'s parent. However, calling // Parse on "<a><table><a>" does not return an error, but the result has an <a> // element with an <a> child, and is therefore not 'well-formed'. // // Programmatically constructed trees are typically also 'well-formed', but it // is possible to construct a tree that looks innocuous but, when rendered and // re-parsed, results in a different tree. A simple example is that a solitary // text node would become a tree containing <html>, <head> and <body> elements. // Another example is that the programmatic equivalent of "a<head>b</head>c" // becomes "<html><head><head/><body>abc</body></html>". func Render(w io.Writer, n *Node) error { … } var plaintextAbort … func render(w writer, n *Node) error { … } func render1(w writer, n *Node) error { … } func childTextNodesAreLiteral(n *Node) bool { … } // writeQuoted writes s to w surrounded by quotes. Normally it will use double // quotes, but if s contains a double quote, it will use single quotes. // It is used for writing the identifiers in a doctype declaration. // In valid HTML, they can't contain both types of quotes. func writeQuoted(w writer, s string) error { … } var voidElements …