1
0
mirror of https://github.com/golang/go synced 2024-11-06 11:36:16 -07:00

go/doc: skip escaping comments in pre-formatted blocks

CL 150377 made the change of converting smart quotes to their html escaped entities
for ToHTML, and to unicode quotes for ToText. But for ToText, the change
converted the quotes in pre-formatted text too.

This fixes that behavior to not touch any text in pre-formatted blocks, which also
makes the behavior consistent with ToHTML.

Fixes #29730

Change-Id: I58e0216cbdbe189d06d82147e5a02b620af14734
Reviewed-on: https://go-review.googlesource.com/c/162922
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Agniva De Sarker 2019-02-18 14:43:06 +05:30 committed by Daniel Martí
parent 39fa3f171c
commit da50e10c2e
2 changed files with 8 additions and 1 deletions

View File

@ -445,7 +445,6 @@ func ToText(w io.Writer, text string, indent, preIndent string, width int) {
w.Write([]byte("\n"))
} else {
w.Write([]byte(preIndent))
line = convertQuotes(line)
w.Write([]byte(line))
}
}

View File

@ -126,6 +126,14 @@ $ pre
$ pre2
`,
},
{
in: "Para.\n\tshould not be ``escaped''",
out: []block{
{opPara, []string{"Para.\n"}},
{opPre, []string{"should not be ``escaped''"}},
},
text: ". Para.\n\n$ should not be ``escaped''",
},
}
func TestBlocks(t *testing.T) {