Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): invalid parsing of link location #443

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions pkg/parser/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,31 @@ next lines`
Expect(source).To(BecomeDocumentBlock(expected))
})

It("external link with more text afterwards", func() {
source := `a link to https://foo.bar and more text`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
{
types.StringElement{Content: "a link to "},
types.InlineLink{
Location: types.Location{
types.StringElement{
Content: "https://foo.bar",
},
},
Attributes: types.ElementAttributes{},
},
types.StringElement{Content: " and more text"},
},
},
}
Expect(source).To(BecomeDocumentBlock(expected))
})

Context("text attribute with comma", func() {

It("relative link only with text having comma", func() {
It("external link only with text having comma", func() {
source := `a link to http://website.com[A, B, and C]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Expand All @@ -211,7 +233,7 @@ next lines`
Expect(source).To(BecomeDocumentBlock(expected))
})

It("relative link only with doublequoted text having comma", func() {
It("external link only with doublequoted text having comma", func() {
source := `a link to http://website.com["A, B, and C"]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Expand All @@ -238,7 +260,7 @@ next lines`
Expect(source).To(BecomeDocumentBlock(expected))
})

It("relative link with doublequoted text having comma and other attrs", func() {
It("external link with doublequoted text having comma and other attrs", func() {
source := `a link to http://website.com["A, B, and C", role=foo]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down Expand Up @@ -266,7 +288,7 @@ next lines`
Expect(source).To(BecomeDocumentBlock(expected))
})

It("relative link with text having comma and other attributes", func() {
It("external link with text having comma and other attributes", func() {
source := `a link to http://website.com[A, B, and C, role=foo]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down Expand Up @@ -669,6 +691,7 @@ Test 2: link:/test/a%20b[with encoded space]`
}
Expect(source).To(BecomeDocumentBlock(expected))
})

})

})
Expand Down
Loading