Skip to content

Commit

Permalink
feat(parser): support anchors in terms of labeled lists (#932)
Browse files Browse the repository at this point in the history
Fixes #931

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Feb 10, 2022
1 parent a396994 commit 34faf3b
Show file tree
Hide file tree
Showing 4 changed files with 7,422 additions and 7,347 deletions.
56 changes: 53 additions & 3 deletions pkg/parser/cross_reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,61 @@ some content`
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("to term in labeled list", func() {
source := `[[a_term]]term::
// a comment
Here's a reference to the definition of <<a_term>>.`
expected := &types.Document{
Elements: []interface{}{
&types.List{
Kind: types.LabeledListKind,
Elements: []types.ListElement{
&types.LabeledListElement{
Style: types.DoubleColons,
Term: []interface{}{
&types.InlineLink{
Attributes: types.Attributes{
types.AttrID: "a_term",
},
},
&types.StringElement{
Content: "term",
},
},
},
},
},
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "Here’s a reference to the definition of ", // note that the quote is transformed
},
&types.InternalCrossReference{
ID: "a_term",
},
&types.StringElement{
Content: ".",
},
},
},
},
ElementReferences: types.ElementReferences{
"a_term": []interface{}{
&types.StringElement{ // the term content, excluding the inline anchor
Content: "term",
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})
})

Context("external references", func() {

It("external cross reference to other doc with plain text location and rich label", func() {
It("to other doc with plain text location and rich label", func() {
source := `some content linked to xref:another-doc.adoc[*another doc*]!`
expected := &types.Document{
Elements: []interface{}{
Expand Down Expand Up @@ -404,7 +454,7 @@ some content`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("external cross reference to other doc with document attribute in location", func() {
It("to other doc with document attribute in location", func() {
source := `some content linked to xref:{foo}.adoc[another doc]!`
expected := &types.Document{
Elements: []interface{}{
Expand All @@ -431,7 +481,7 @@ some content`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("external cross reference to other doc with document attribute in location and label with special chars", func() {
It("to other doc with document attribute in location and label with special chars", func() {
source := `
:foo: another-doc.adoc
Expand Down
Loading

0 comments on commit 34faf3b

Please sign in to comment.