Skip to content

Commit

Permalink
fix(gengapic): fix linkParser regexp to support multi-line link tags (#…
Browse files Browse the repository at this point in the history
…1098)

closes: #1097
  • Loading branch information
quartzmo authored Aug 4, 2022
1 parent 6480461 commit 863675e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/gengapic/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"gitlab.com/golang-commonmark/markdown"
)

var linkParser = regexp.MustCompile(`<a href=["'](.+)["']`)
var linkParser = regexp.MustCompile(`<a\s+href=["'](.+)["']`)
var referenceParser = regexp.MustCompile(`\[([a-zA-Z1-9._]+)\]\[[a-zA-Z1-9._]*\]`)

func mdPlain(s string) string {
Expand Down
4 changes: 4 additions & 0 deletions internal/gengapic/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func TestMDPlain(t *testing.T) {
in: "html <a href=\"/link/to/some#thing\">\n with a softbreak</a> <br> test",
want: "html with a softbreak (at /link/to/some#thing) \n test",
},
{
in: "html <a \n href=\"/link/to/some#thing\">\n with a linebreak in tag</a> <br> test",
want: "html with a linebreak in tag (at /link/to/some#thing) \n test",
},
{
in: "link to [a search engine](https://www.google.com) with request type [Search][foo.bar_baz.v1.Search], [biz][][buz][baz].",
want: "link to a search engine (at https://www.google.com) with request type Search, bizbuz.",
Expand Down

0 comments on commit 863675e

Please sign in to comment.