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

refactor(types): rename func to init AttributeReferences #1043

Merged
merged 1 commit into from
Jun 13, 2022
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
76 changes: 74 additions & 2 deletions pkg/parser/attribute_substitution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var _ = Describe("attribute substitutions", func() {

Context("in final documents", func() {

It("paragraph with attribute substitution", func() {
It("paragraph with attribute reference", func() {
source := `:author: Xavier

a paragraph written by {author}.`
Expand Down Expand Up @@ -136,7 +136,7 @@ This journey continues`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("paragraph with attribute substitution from front-matter", func() {
It("paragraph with attribute reference from front-matter", func() {
source := `---
author: Xavier
---
Expand All @@ -160,5 +160,77 @@ a paragraph written by {author}.`
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("link with attribute reference with hyphen", func() {
source := `:download-version: 1.0.0

a link to https://example.com/version/v{download-version}[here]`

expected := &types.Document{
Elements: []interface{}{
&types.DocumentHeader{
Elements: []interface{}{
&types.AttributeDeclaration{
Name: "download-version",
Value: "1.0.0",
},
},
},
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "a link to ",
},
&types.InlineLink{
Attributes: types.Attributes{
types.AttrInlineLinkText: "here",
},
Location: &types.Location{
Scheme: "https://",
Path: "example.com/version/v1.0.0",
},
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("link with unknown attribute reference in URL", func() {
source := `:version: 1.0.0

a link to https://example.com/version/v{unknown}[here]`

expected := &types.Document{
Elements: []interface{}{
&types.DocumentHeader{
Elements: []interface{}{
&types.AttributeDeclaration{
Name: "version",
Value: "1.0.0",
},
},
},
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "a link to ",
},
&types.InlineLink{
Attributes: types.Attributes{
types.AttrInlineLinkText: "here",
},
Location: &types.Location{
Scheme: "https://",
Path: "example.com/version/v{unknown}",
},
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})
})
})
Loading