Skip to content

Commit

Permalink
fix(parser): delimited block immediately after paragraph
Browse files Browse the repository at this point in the history
do not include raw content within paragraph.

Fixes #1008

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon committed May 2, 2022
1 parent b8014f8 commit 35f00eb
Show file tree
Hide file tree
Showing 5 changed files with 9,052 additions and 7,706 deletions.
27 changes: 27 additions & 0 deletions pkg/parser/delimited_block_listing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,33 @@ some listing code
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("immediately after a paragraph", func() {
source := `a paragraph.
----
some listing code
----`
expected := &types.Document{
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "a paragraph.",
},
},
},
&types.DelimitedBlock{
Kind: types.Listing,
Elements: []interface{}{
&types.StringElement{
Content: "some listing code",
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("with unclosed delimiter", func() {
source := `----
End of file here.`
Expand Down
55 changes: 55 additions & 0 deletions pkg/parser/delimited_block_literal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,61 @@ a normal paragraph.`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("after a paragraph", func() {
source := `a normal paragraph.
....
some delimited content
....`
expected := &types.Document{
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "a normal paragraph.",
},
},
},
&types.DelimitedBlock{
Kind: types.Literal,
Elements: []interface{}{
&types.StringElement{
Content: "some delimited content",
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("immediately after a paragraph", func() {
source := `a normal paragraph.
....
some delimited content
....`
expected := &types.Document{
Elements: []interface{}{
&types.Paragraph{
Elements: []interface{}{
&types.StringElement{
Content: "a normal paragraph.",
},
},
},
&types.DelimitedBlock{
Kind: types.Literal,
Elements: []interface{}{
&types.StringElement{
Content: "some delimited content",
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

Context("with variable delimiter length", func() {

It("with 5 chars", func() {
Expand Down
Loading

0 comments on commit 35f00eb

Please sign in to comment.