From 0d6d40c7174e7c5d60c181cac06ca34ead42ecaa Mon Sep 17 00:00:00 2001 From: Xavier Coulon Date: Sat, 20 Nov 2021 13:23:39 +0100 Subject: [PATCH] fix(parser): links with underscores (#857) Add tests to verify that it now works, but was already fixed by #843 Closes #849 Signed-off-by: Xavier Coulon --- pkg/parser/link_test.go | 40 ++++++++++++++++++++++++++++ pkg/renderer/sgml/html5/link_test.go | 9 +++++++ 2 files changed, 49 insertions(+) diff --git a/pkg/parser/link_test.go b/pkg/parser/link_test.go index 58ef0875..da759e54 100644 --- a/pkg/parser/link_test.go +++ b/pkg/parser/link_test.go @@ -1310,6 +1310,46 @@ a link to {scheme}:{path}[] and https://foo.com` Expect(ParseDocument(source)).To(MatchDocument(expected)) }) + It("links with underscores", func() { + source := "link:a_[A] link:a_[A]" + expected := &types.Document{ + Elements: []interface{}{ + &types.Paragraph{ + Elements: []interface{}{ + &types.InlineLink{ + Attributes: types.Attributes{ + types.AttrInlineLinkText: "A", + }, + Location: &types.Location{ + Path: []interface{}{ + &types.StringElement{ + Content: "a_", + }, + }, + }, + }, + &types.StringElement{ + Content: " ", + }, + &types.InlineLink{ + Attributes: types.Attributes{ + types.AttrInlineLinkText: "A", + }, + Location: &types.Location{ + Path: []interface{}{ + &types.StringElement{ + Content: "a_", + }, + }, + }, + }, + }, + }, + }, + } + Expect(ParseDocument(source)).To(MatchDocument(expected)) + }) + Context("text attribute with comma", func() { It("relative link only with text having comma", func() { diff --git a/pkg/renderer/sgml/html5/link_test.go b/pkg/renderer/sgml/html5/link_test.go index 81a1dba2..a682cef5 100644 --- a/pkg/renderer/sgml/html5/link_test.go +++ b/pkg/renderer/sgml/html5/link_test.go @@ -328,6 +328,15 @@ a link to {scheme}:{path}[] and https://foo.baz` expected := `

a link to {path} and https://foo.baz

+` + Expect(RenderHTML(source)).To(MatchHTML(expected)) + }) + + It("links with underscores", func() { + source := "link:a_[A] link:a_[A]" + expected := `
+

A A

+
` Expect(RenderHTML(source)).To(MatchHTML(expected)) })