diff --git a/pkg/mark/link.go b/pkg/mark/link.go index c107c64c..7ba95023 100644 --- a/pkg/mark/link.go +++ b/pkg/mark/link.go @@ -169,7 +169,7 @@ func SubstituteLinks(markdown []byte, links []LinkSubstitution) []byte { func parseLinks(markdown string) []markdownLink { // Matches links but not inline images - re := regexp.MustCompile(`[^\!]\[[^\]]+\]\((([^\)#]+)?#?([^\)]+)?)\)`) + re := regexp.MustCompile(`[^\!]\[.+\]\((([^\)#]+)?#?([^\)]+)?)\)`) matches := re.FindAllStringSubmatch(markdown, -1) links := make([]markdownLink, len(matches)) diff --git a/pkg/mark/link_test.go b/pkg/mark/link_test.go index ace26010..7b790787 100644 --- a/pkg/mark/link_test.go +++ b/pkg/mark/link_test.go @@ -15,6 +15,7 @@ func TestParseLinks(t *testing.T) { [Image link that should be put as attachment](../path/to/example.png) [relative link without dots](relative-link-without-dots.md) [relative link without dots but with hash](relative-link-without-dots-but-with-hash.md#hash) + [example [example]](example.md) ` links := parseLinks(markdown) @@ -47,5 +48,6 @@ func TestParseLinks(t *testing.T) { assert.Equal(t, "relative-link-without-dots-but-with-hash.md", links[6].filename) assert.Equal(t, "hash", links[6].hash) - assert.Equal(t, len(links), 7) + assert.Equal(t, "example.md", links[7].full) + assert.Equal(t, len(links), 8) } diff --git a/pkg/mark/testdata/links-droph1.html b/pkg/mark/testdata/links-droph1.html index b002880d..9a35df06 100644 --- a/pkg/mark/testdata/links-droph1.html +++ b/pkg/mark/testdata/links-droph1.html @@ -7,6 +7,7 @@ Use footnotes link 1 +Use Link [Text]

    diff --git a/pkg/mark/testdata/links-stripnewlines.html b/pkg/mark/testdata/links-stripnewlines.html index b002880d..9a35df06 100644 --- a/pkg/mark/testdata/links-stripnewlines.html +++ b/pkg/mark/testdata/links-stripnewlines.html @@ -7,6 +7,7 @@ Use footnotes link 1 +Use Link [Text]

      diff --git a/pkg/mark/testdata/links.html b/pkg/mark/testdata/links.html index b002880d..9a35df06 100644 --- a/pkg/mark/testdata/links.html +++ b/pkg/mark/testdata/links.html @@ -7,6 +7,7 @@ Use footnotes link 1 +Use Link [Text]

        diff --git a/pkg/mark/testdata/links.md b/pkg/mark/testdata/links.md index 855b0af9..c6bbe7d6 100644 --- a/pkg/mark/testdata/links.md +++ b/pkg/mark/testdata/links.md @@ -17,3 +17,4 @@ Use [page link with spaces]() Use footnotes link [^1] [^1]: a footnote link +Use [Link [Text]](foo)