Skip to content

Commit

Permalink
feat(renderer): support table ID (#868)
Browse files Browse the repository at this point in the history
also, verifies that cross references work in list element continuations
(#837)

Fixes #867
Fixes #837

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Nov 22, 2021
1 parent 496a869 commit e701182
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 168 deletions.
82 changes: 72 additions & 10 deletions pkg/parser/ordered_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ var _ = Describe("ordered lists", func() {

Context("elements without numbers", func() {

It("ordered list with simple unnumbered elements", func() {
It("with simple unnumbered elements", func() {
source := `. a
. b`

Expand Down Expand Up @@ -344,7 +344,7 @@ var _ = Describe("ordered lists", func() {
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with unnumbered elements", func() {
It("with unnumbered elements", func() {
source := `. element 1
. element 2`

Expand Down Expand Up @@ -380,7 +380,7 @@ var _ = Describe("ordered lists", func() {
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with custom numbering on child elements with tabs ", func() {
It("with custom numbering on child elements with tabs ", func() {
// note: the [upperroman] attribute must be at the beginning of the line
source := `. element 1
.. element 1.1
Expand Down Expand Up @@ -491,7 +491,7 @@ var _ = Describe("ordered lists", func() {
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with all default styles and blank lines", func() {
It("with all default styles and blank lines", func() {
source := `. level 1
.. level 2
Expand Down Expand Up @@ -588,7 +588,7 @@ var _ = Describe("ordered lists", func() {
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with all default styles and no blank line", func() {
It("with all default styles and no blank line", func() {
source := `. level 1
.. level 2
... level 3
Expand Down Expand Up @@ -680,7 +680,7 @@ var _ = Describe("ordered lists", func() {

Context("numbered elements", func() {

It("ordered list with simple numbered elements", func() {
It("with simple numbered elements", func() {
source := `1. a
2. b`
expected := &types.Document{
Expand Down Expand Up @@ -830,7 +830,7 @@ var _ = Describe("ordered lists", func() {
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with numbered elements", func() {
It("with numbered elements", func() {
source := `1. element 1
a. element 1.a
2. element 2
Expand Down Expand Up @@ -900,7 +900,7 @@ b. element 2.a`

Context("list element continuation", func() {

It("ordered list with element continuation - case 1", func() {
It("case 1", func() {
source := `. foo
+
----
Expand Down Expand Up @@ -960,7 +960,7 @@ another delimited block
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with element continuation - case 2", func() {
It("case 2", func() {
source := `. {blank}
+
----
Expand Down Expand Up @@ -1019,7 +1019,7 @@ print("two")
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("ordered list with element continuation - case 3", func() {
It("case 3", func() {
// continuation with "continued element" being a list element (ie, kinda invalid/empty continuation in the middle of a list)
source := `. element 1
+
Expand Down Expand Up @@ -1082,6 +1082,68 @@ a paragraph
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("case 4", func() {
source := `. cookie
+
image::cookie.png[]
+
. chocolate
+
image::chocolate.png[]`
expected := &types.Document{
Elements: []interface{}{
&types.List{
Kind: types.OrderedListKind,
Elements: []types.ListElement{
&types.OrderedListElement{
Style: types.Arabic,
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "cookie",
},
},
},
&types.ImageBlock{
Location: &types.Location{
Path: []interface{}{
&types.StringElement{
Content: "cookie.png",
},
},
},
},
},
},
&types.OrderedListElement{
Style: types.Arabic,
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "chocolate",
},
},
},
&types.ImageBlock{
Location: &types.Location{
Path: []interface{}{
&types.StringElement{
Content: "chocolate.png",
},
},
},
},
},
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})
})
})
})
144 changes: 71 additions & 73 deletions pkg/parser/unordered_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ on 2 lines, too.`

Context("list element continuation", func() {

It("with item continuation - case 1", func() {
It("case 1", func() {
source := `* foo
+
----
Expand Down Expand Up @@ -1063,7 +1063,7 @@ another delimited block
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("with item continuation - case 2", func() {
It("case 2", func() {
source := `.Unordered, complex
* level 1
** level 2
Expand Down Expand Up @@ -1199,7 +1199,7 @@ The {plus} symbol is on a new line.
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("with list element continuation - case 3", func() {
It("case 3", func() {
source := `- here
+
_there_`
Expand Down Expand Up @@ -1240,76 +1240,6 @@ _there_`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("without item continuation", func() {
source := `* foo
----
a delimited block
----
* bar
----
another delimited block
----`
expected := &types.Document{
Elements: []interface{}{
&types.List{
Kind: types.UnorderedListKind,
Elements: []types.ListElement{
&types.UnorderedListElement{
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{Content: "foo"},
},
},
},
},
},
},
&types.DelimitedBlock{
Kind: types.Listing,
Elements: []interface{}{
&types.StringElement{
Content: "a delimited block",
},
},
},
&types.List{
Kind: types.UnorderedListKind,
Elements: []types.ListElement{
&types.UnorderedListElement{
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{Content: "bar"},
},
},
},
},
},
},
&types.DelimitedBlock{
Kind: types.Listing,
Elements: []interface{}{
&types.StringElement{
Content: "another delimited block",
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})
})

Context("attach to ancestor", func() {

It("attach to grandparent item", func() {
source := `* grandparent list element
** parent list element
Expand Down Expand Up @@ -1453,5 +1383,73 @@ paragraph attached to parent list element`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})
})

It("without item continuation", func() {
source := `* foo
----
a delimited block
----
* bar
----
another delimited block
----`
expected := &types.Document{
Elements: []interface{}{
&types.List{
Kind: types.UnorderedListKind,
Elements: []types.ListElement{
&types.UnorderedListElement{
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{Content: "foo"},
},
},
},
},
},
},
&types.DelimitedBlock{
Kind: types.Listing,
Elements: []interface{}{
&types.StringElement{
Content: "a delimited block",
},
},
},
&types.List{
Kind: types.UnorderedListKind,
Elements: []types.ListElement{
&types.UnorderedListElement{
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{Content: "bar"},
},
},
},
},
},
},
&types.DelimitedBlock{
Kind: types.Listing,
Elements: []interface{}{
&types.StringElement{
Content: "another delimited block",
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

})
})
Loading

0 comments on commit e701182

Please sign in to comment.