From: Gary Burd Date: Fri, 3 Feb 2012 01:02:05 +0000 (-0800) Subject: go/doc: Fix URL linking in ToHTML. X-Git-Tag: weekly.2012-02-07~113 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b9474de2bef8469a61b22ba17f18c28ab4c58fd8;p=gostls13.git go/doc: Fix URL linking in ToHTML. Fixes issue: 2832 R=rsc, gri CC=golang-dev https://golang.org/cl/5616060 --- diff --git a/src/pkg/go/doc/comment.go b/src/pkg/go/doc/comment.go index e50cdd86e6..6f0edd4bad 100644 --- a/src/pkg/go/doc/comment.go +++ b/src/pkg/go/doc/comment.go @@ -56,7 +56,7 @@ const ( filePart + `([:.,]` + filePart + `)*` ) -var matchRx = regexp.MustCompile(`(` + identRx + `)|(` + urlRx + `)`) +var matchRx = regexp.MustCompile(`(` + urlRx + `)|(` + identRx + `)`) var ( html_a = []byte(`http://www.google.com/`}, + {"https://www.google.com/", `https://www.google.com/`}, + {"http://www.google.com/path.", `http://www.google.com/path.`}, + {"(http://www.google.com/)", `(http://www.google.com/)`}, + {"Foo bar http://example.com/ quux!", `Foo bar http://example.com/ quux!`}, + {"Hello http://example.com/%2f/ /world.", `Hello http://example.com/%2f/ /world.`}, + {"Lorem http: ipsum //host/path", "Lorem http: ipsum //host/path"}, + {"javascript://is/not/linked", "javascript://is/not/linked"}, +} + +func TestEmphasize(t *testing.T) { + for i, tt := range emphasizeTests { + var buf bytes.Buffer + emphasize(&buf, tt.in, nil, true) + out := buf.String() + if out != tt.out { + t.Errorf("#%d: mismatch\nhave: %v\nwant: %v", i, out, tt.out) + } + } +}