]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: skip escaping comments in pre-formatted blocks
authorAgniva De Sarker <agnivade@yahoo.co.in>
Mon, 18 Feb 2019 09:13:06 +0000 (14:43 +0530)
committerDaniel Martí <mvdan@mvdan.cc>
Tue, 26 Feb 2019 18:51:37 +0000 (18:51 +0000)
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>
src/go/doc/comment.go
src/go/doc/comment_test.go

index 0ec42643fdf82fa5f3c5fba537602b70dfc83fae..73857330fa7158aa3dcfd647234cf815d7c96711 100644 (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))
                                }
                        }
index e0adeb2f5cf107d50c4d291cc998377d3db6672d..0687f3a62b344222b1aac075b22fc561f2598d99 100644 (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) {