Skip to content

Commit

Permalink
fix(parser): links with underscores (#857)
Browse files Browse the repository at this point in the history
Add tests to verify that it now works, but was already fixed by #843

Closes #849

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Nov 20, 2021
1 parent dbec12b commit 0d6d40c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
40 changes: 40 additions & 0 deletions pkg/parser/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
9 changes: 9 additions & 0 deletions pkg/renderer/sgml/html5/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ a link to {scheme}:{path}[] and https://foo.baz`
expected := `<div class="paragraph">
<p>a link to <a href="{path}" class="bare">{path}</a> and <a href="https://foo.baz" class="bare">https://foo.baz</a></p>
</div>
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
})

It("links with underscores", func() {
source := "link:a_[A] link:a_[A]"
expected := `<div class="paragraph">
<p><a href="a_">A</a> <a href="a_">A</a></p>
</div>
`
Expect(RenderHTML(source)).To(MatchHTML(expected))
})
Expand Down

0 comments on commit 0d6d40c

Please sign in to comment.