Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/doc: document that empty single quotes (39) are converted to unicode quote (8221) #30955

Closed
gokcehan opened this issue Mar 20, 2019 · 6 comments
Closed

Comments

@gokcehan
Copy link

@gokcehan gokcehan commented Mar 20, 2019

Double empty single quotes (ascii 39 as in '') in the documentation are automatically converted to a unicode quote (8221 as in ) for some reason. I could not find this documented anywhere. I find this behavior strange. Is this really intentional? If so, how can I escape double empty single quotes then?

What version of Go are you using (go version)?

$ go version
go version go1.12 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/gokce/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/gokce/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build984363357=/tmp/go-build -gno-record-gcc-switches"

What did you do?

mkdir /tmp/quote-test
cd /tmp/quote-test
cat << 'END' > doc.go
// empty single quote '' or non-empty single quote 'x' in your doc
package main
END
go doc

What did you expect to see?

empty single quote '' or non-empty single quote 'x' in your doc

What did you see instead?

empty single quote ” or non-empty single quote 'x' in your doc
@ALTree ALTree changed the title /x/tools/cmd/godoc empty single quotes (39) are converted to unicode quote (8221) /x/tools/cmd/godoc: empty single quotes (39) are converted to unicode quote (8221) Mar 21, 2019
@ALTree ALTree added this to the Unplanned milestone Mar 21, 2019
@ALTree

This comment has been minimized.

Copy link
Member

@ALTree ALTree commented Mar 21, 2019

Definitely intentional. Probably could document this somewhere.

@gokcehan

This comment has been minimized.

Copy link
Author

@gokcehan gokcehan commented Mar 21, 2019

@ALTree So then is there a way to escape it? I understand this can be useful for regular text but this also happens in indented pre blocks. There can be code or configuration pieces in there having '' characters. Maybe is it a good idea to disable this behavior just in pre blocks? Also I realized this only happens in text output and html doc in godoc.org seems to have the original single quote characters.

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Mar 21, 2019

Don't think there is a way to escape it. Probably @griesemer will know.

I understand this can be useful for regular text but this also happens in indented pre blocks.

It does not anymore in master :) We fixed that. da50e10

Also I realized this only happens in text output and html doc in godoc.org seems to have the original single quote characters.

Not really. The html output converts them to &rdquo;, which is the escaped form of the unicode quotes. Probably you are seeing an older godoc ?

It will be good to document this in go/doc ToText and ToHTML.

@agnivade agnivade changed the title /x/tools/cmd/godoc: empty single quotes (39) are converted to unicode quote (8221) go/doc: document that empty single quotes (39) are converted to unicode quote (8221) Mar 21, 2019
@gokcehan

This comment has been minimized.

Copy link
Author

@gokcehan gokcehan commented Mar 21, 2019

@agnivade Glad to hear this is disabled in pre blocks which should be fine for most cases. This issue is then basically a dup for #29730 which I didn't see before. I guess this can either be closed or left open until a possible documentation change.

I had only checked pre blocks in godoc.org which uses &#39;&#39; and it is copy pasted correctly. Maybe they are using a much older version or a newer version after the change you mention.

@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Mar 21, 2019

The pre block change is only in master. I don't think godoc.org deploys from tip.

Let's keep this open to make a doc change.

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 10, 2019

Change https://golang.org/cl/206122 mentions this issue: go/doc: document unicode quoting conversion

@gopherbot gopherbot closed this in b60c7a5 Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.