aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/html/parse.go
diff options
context:
space:
mode:
authorAndrew Balholm <andybalholm@gmail.com>2011-11-24 13:15:09 +1100
committerNigel Tao <nigeltao@golang.org>2011-11-24 13:15:09 +1100
commitaf081cd43ee3a69f89c5a00ab830111cae99d94a (patch)
tree8a94938d19f2f3fe139d5cc021821d112b5be562 /src/pkg/html/parse.go
parent63e48ccd8ea9399b411bf092f53ad8cd606946a0 (diff)
downloadgo-af081cd43ee3a69f89c5a00ab830111cae99d94a.tar.xz
html: ingore newline at the start of a <pre> block
Pass tests3.dat, test 4: <!DOCTYPE html><html><head></head><body><pre>\n</pre></body></html> | <!DOCTYPE html> | <html> | <head> | <body> | <pre> Also pass tests through test 11: <!DOCTYPE html><pre>&#x0a;&#x0a;A</pre> R=nigeltao CC=golang-dev https://golang.org/cl/5437051
Diffstat (limited to 'src/pkg/html/parse.go')
-rw-r--r--src/pkg/html/parse.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/pkg/html/parse.go b/src/pkg/html/parse.go
index 041c5390ed..36a5fd2fdc 100644
--- a/src/pkg/html/parse.go
+++ b/src/pkg/html/parse.go
@@ -628,6 +628,23 @@ func copyAttributes(dst *Node, src Token) {
func inBodyIM(p *parser) bool {
switch p.tok.Type {
case TextToken:
+ switch n := p.oe.top(); n.Data {
+ case "pre", "listing", "textarea":
+ if len(n.Child) == 0 {
+ // Ignore a newline at the start of a <pre> block.
+ d := p.tok.Data
+ if d != "" && d[0] == '\r' {
+ d = d[1:]
+ }
+ if d != "" && d[0] == '\n' {
+ d = d[1:]
+ }
+ if d == "" {
+ return true
+ }
+ p.tok.Data = d
+ }
+ }
p.reconstructActiveFormattingElements()
p.addText(p.tok.Data)
p.framesetOK = false