]> Cypherpunks repositories - gostls13.git/commit
go/doc: simplify and robustify link detection logic
authorJoe Tsai <joetsai@digital-static.net>
Fri, 16 Feb 2018 22:52:10 +0000 (14:52 -0800)
committerRobert Griesemer <gri@golang.org>
Fri, 14 Dec 2018 00:41:25 +0000 (00:41 +0000)
commit190a5f8fd2f360c22c11b290796ae7fc0fa5607c
tree1e4205d303ebb0f814abc6a91733a44bcd3bc951
parenta6293995c55659f51e0662e7656f395633c99b5b
go/doc: simplify and robustify link detection logic

To fix #5043, we added logic to allow balanced pairs of parenthesis
so that we could match URLs like:
http://example.com/some_resource(foo)

Howewer, such logic breaks when parsing something like the following:
art by [https://example.com/person][Person Name]].
such that the following is considered the link:
https://example.com/person][Person

Since the logic added in #5043 was just a heuristic, we adjust
the heuristic that in addition to requiring balanced pairs,
the first parenthesis must be an opening one.

For further robustness, we apply this heuristic to
parenthesis, braces, and brackets.

Fixes #22285

Change-Id: I23b728a644e35ce3995b05a79129cad2c1e3b1ce
Reviewed-on: https://go-review.googlesource.com/c/94876
Run-TryBot: Robert Griesemer <gri@golang.org>
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