aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/html/render.go
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2011-11-02 09:42:25 +1100
committerNigel Tao <nigeltao@golang.org>2011-11-02 09:42:25 +1100
commit90b76c0f3e3356e17c03baae3e20a4a11c2a6f10 (patch)
tree26b8cc3d46b54858255624e2024c3adeb08c8f02 /src/pkg/html/render.go
parentf753e3facda2a9845caf7e8aed0e8a122d6b6e48 (diff)
downloadgo-90b76c0f3e3356e17c03baae3e20a4a11c2a6f10.tar.xz
html: refactor the blacklist for the "render and re-parse" test.
R=andybalholm CC=golang-dev, mikesamuel https://golang.org/cl/5331056
Diffstat (limited to 'src/pkg/html/render.go')
-rw-r--r--src/pkg/html/render.go31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/pkg/html/render.go b/src/pkg/html/render.go
index d5dc448433..0522b6ef92 100644
--- a/src/pkg/html/render.go
+++ b/src/pkg/html/render.go
@@ -19,17 +19,28 @@ type writer interface {
// Render renders the parse tree n to the given writer.
//
-// For 'well-formed' parse trees, calling Parse on the output of Render will
-// result in a clone of the original tree.
+// 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.
//
-// 'Well-formed' is not formally specified, but calling Parse on arbitrary
-// input results in a 'well-formed' parse tree if Parse does not return an
-// error. Programmatically constructed trees are typically also 'well-formed',
-// but it is possible to construct a tree that, 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>".
+// 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) os.Error {
if x, ok := w.(writer); ok {
return render(x, n)