[go] go/doc/comment: never rewrite into smart quotes

2 views
Skip to first unread message

Sean Liao (Gerrit)

unread,
Dec 23, 2025, 3:50:46 PM (2 days ago) Dec 23
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Sean Liao has uploaded the change for review

Commit message

go/doc/comment: never rewrite into smart quotes

Since Go source code is in UTF-8, smart quotes
should be part of the original source
if they are desired. Characters important to
programming languages should not be mangled.

Fixes #54312
Fixes #76975
Change-Id: I20331669bb691eafe66ebcc3f8513c4f6a6a6964

Change diff

diff --git a/src/go/doc/comment/parse.go b/src/go/doc/comment/parse.go
index 4d5784a..eb67562 100644
--- a/src/go/doc/comment/parse.go
+++ b/src/go/doc/comment/parse.go
@@ -939,28 +939,7 @@
continue
}
}
- switch {
- case strings.HasPrefix(t, "``"):
- if len(t) >= 3 && t[2] == '`' {
- // Do not convert `` inside ```, in case people are mistakenly writing Markdown.
- i += 3
- for i < len(t) && t[i] == '`' {
- i++
- }
- break
- }
- writeUntil(i)
- w.WriteRune('“')
- i += 2
- wrote = i
- case strings.HasPrefix(t, "''"):
- writeUntil(i)
- w.WriteRune('”')
- i += 2
- wrote = i
- default:
- i++
- }
+ i++
}
flush(len(s))
return out
diff --git a/src/go/doc/comment/testdata/quote.txt b/src/go/doc/comment/testdata/quote.txt
index b64adae..cfe945a 100644
--- a/src/go/doc/comment/testdata/quote.txt
+++ b/src/go/doc/comment/testdata/quote.txt
@@ -1,15 +1,15 @@
-- input --
-Doubled single quotes like `` and '' turn into Unicode double quotes,
-but single quotes ` and ' do not.
+Doubled single quotes like `` and '' don't turn into Unicode double quotes,
+and neither do single quotes ` and '.
Misplaced markdown fences ``` do not either.
-- gofmt --
-Doubled single quotes like “ and ” turn into Unicode double quotes,
-but single quotes ` and ' do not.
+Doubled single quotes like `` and '' don't turn into Unicode double quotes,
+and neither do single quotes ` and '.
Misplaced markdown fences ``` do not either.
-- text --
-Doubled single quotes like “ and ” turn into Unicode double quotes, but single
-quotes ` and ' do not. Misplaced markdown fences ``` do not either.
+Doubled single quotes like `` and '' don't turn into Unicode double quotes, and
+neither do single quotes ` and '. Misplaced markdown fences ``` do not either.
-- html --
-<p>Doubled single quotes like “ and ” turn into Unicode double quotes,
-but single quotes ` and &apos; do not.
+<p>Doubled single quotes like `` and &apos;&apos; don&apos;t turn into Unicode double quotes,
+and neither do single quotes ` and &apos;.
Misplaced markdown fences ``` do not either.
diff --git a/src/go/doc/synopsis_test.go b/src/go/doc/synopsis_test.go
index 158c734..949859c 100644
--- a/src/go/doc/synopsis_test.go
+++ b/src/go/doc/synopsis_test.go
@@ -35,7 +35,7 @@
{"All Rights reserved. Package foo does bar.", 20, ""},
{"All rights reserved. Package foo does bar.", 20, ""},
{"Authors: f...@bar.com. Package foo does bar.", 21, ""},
- {"typically invoked as ``go tool asm'',", 37, "typically invoked as “go tool asm”,"},
+ {"typically invoked as ``go tool asm'',", 37, "typically invoked as ``go tool asm'',"},
}

func TestSynopsis(t *testing.T) {

Change information

Files:
  • M src/go/doc/comment/parse.go
  • M src/go/doc/comment/testdata/quote.txt
  • M src/go/doc/synopsis_test.go
Change size: S
Delta: 3 files changed, 10 insertions(+), 31 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I20331669bb691eafe66ebcc3f8513c4f6a6a6964
Gerrit-Change-Number: 732420
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Liao <se...@liao.dev>
unsatisfied_requirement
satisfied_requirement
open
diffy

Sean Liao (Gerrit)

unread,
Dec 23, 2025, 3:51:01 PM (2 days ago) Dec 23
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Sean Liao voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I20331669bb691eafe66ebcc3f8513c4f6a6a6964
Gerrit-Change-Number: 732420
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Liao <se...@liao.dev>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-Comment-Date: Tue, 23 Dec 2025 20:50:55 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

kortschak (Gerrit)

unread,
Dec 23, 2025, 4:18:26 PM (2 days ago) Dec 23
to goph...@pubsubhelper.golang.org, Go LUCI, Rob Pike, Robert Griesemer, golang-co...@googlegroups.com
Attention needed from Rob Pike, Robert Griesemer and Sean Liao

kortschak voted and added 1 comment

Votes added by kortschak

Code-Review+1

1 comment

Patchset-level comments
Open in Gerrit

Related details

Attention is currently required from:
  • Rob Pike
  • Robert Griesemer
  • Sean Liao
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I20331669bb691eafe66ebcc3f8513c4f6a6a6964
    Gerrit-Change-Number: 732420
    Gerrit-PatchSet: 1
    Gerrit-Owner: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: Rob Pike <r...@golang.org>
    Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
    Gerrit-Reviewer: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: kortschak <d...@kortschak.io>
    Gerrit-Attention: Sean Liao <se...@liao.dev>
    Gerrit-Attention: Rob Pike <r...@golang.org>
    Gerrit-Attention: Robert Griesemer <g...@golang.org>
    Gerrit-Comment-Date: Tue, 23 Dec 2025 21:18:16 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    unsatisfied_requirement
    satisfied_requirement
    open
    diffy

    Rob Pike (Gerrit)

    unread,
    Dec 23, 2025, 4:33:39 PM (2 days ago) Dec 23
    to goph...@pubsubhelper.golang.org, Rob Pike, kortschak, Go LUCI, Robert Griesemer, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer and Sean Liao

    Rob Pike voted Code-Review+2

    Code-Review+2
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    • Sean Liao
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I20331669bb691eafe66ebcc3f8513c4f6a6a6964
    Gerrit-Change-Number: 732420
    Gerrit-PatchSet: 1
    Gerrit-Owner: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: Rob Pike <r...@golang.org>
    Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
    Gerrit-Reviewer: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: kortschak <d...@kortschak.io>
    Gerrit-Attention: Sean Liao <se...@liao.dev>
    Gerrit-Attention: Robert Griesemer <g...@golang.org>
    Gerrit-Comment-Date: Tue, 23 Dec 2025 21:33:30 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Dec 23, 2025, 5:15:49 PM (2 days ago) Dec 23
    to goph...@pubsubhelper.golang.org, Rob Pike, kortschak, Go LUCI, Robert Griesemer, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer and Sean Liao

    Robert Griesemer voted and added 1 comment

    Votes added by Robert Griesemer

    Hold+1

    1 comment

    Patchset-level comments
    Robert Griesemer . resolved

    Not so fast. We need to first a) approve the proposal, and also reconcile it with proposal #54312 which is similar but not identical.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    • Sean Liao
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Holds
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedNo-Wait-Release
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I20331669bb691eafe66ebcc3f8513c4f6a6a6964
    Gerrit-Change-Number: 732420
    Gerrit-PatchSet: 1
    Gerrit-Owner: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: Rob Pike <r...@golang.org>
    Gerrit-Reviewer: Robert Griesemer <g...@golang.org>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-Reviewer: Sean Liao <se...@liao.dev>
    Gerrit-Reviewer: kortschak <d...@kortschak.io>
    Gerrit-Attention: Sean Liao <se...@liao.dev>
    Gerrit-Attention: Robert Griesemer <g...@golang.org>
    Gerrit-Comment-Date: Tue, 23 Dec 2025 22:15:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages