Skip to content

Commit

Permalink
bug(parser): colons, images and icons not supported in list terms
Browse files Browse the repository at this point in the history
Fixes #614
  • Loading branch information
gdamore committed Jun 16, 2020
1 parent 51f6d80 commit 5b60e00
Show file tree
Hide file tree
Showing 6 changed files with 2,258 additions and 2,142 deletions.
34 changes: 34 additions & 0 deletions pkg/parser/document_processing_rearrange_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,23 @@ var _ = Describe("rearrange lists", func() {
},
},
},
types.LabeledListItem{
Level: 2,
Term: []interface{}{
types.StringElement{
Content: "icon:caution[]",
},
},
Elements: []interface{}{
types.Paragraph{
Lines: [][]interface{}{
{
types.StringElement{Content: "description 3"},
},
},
},
},
},
}
expected := []interface{}{
types.LabeledList{
Expand Down Expand Up @@ -456,6 +473,23 @@ var _ = Describe("rearrange lists", func() {
},
},
},
{
Level: 2,
Term: []interface{}{
types.Icon{
Class: "caution",
},
},
Elements: []interface{}{
types.Paragraph{
Lines: [][]interface{}{
{
types.StringElement{Content: "description 3"},
},
},
},
},
},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/icon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ var _ = Describe("icons", func() {
Expect(ParseDraftDocument(source)).To(MatchDraftDocument(expected))
})

// NB: The existing grammar for labeled list items does not support any markup
// in the term text.
// Note that the parsing that occurs here does not include the re-parse of the list item term.
// That is done in second pass.
It("inline icon as labeled list item description", func() {
source := `discount:: icon:tags[alt="Discount"] Cheap cheap!
item 2:: two`
Expand Down
30 changes: 30 additions & 0 deletions pkg/parser/labeled_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,36 @@ level 2::: description 2`
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

It("item with a colon the term", func() {
source := `what: ever:: text`
expected := types.Document{
Elements: []interface{}{
types.LabeledList{
Items: []types.LabeledListItem{
{
Level: 1,
Term: []interface{}{
types.StringElement{
Content: "what: ever",
},
},
Elements: []interface{}{
types.Paragraph{
Lines: [][]interface{}{
{
types.StringElement{Content: "text"},
},
},
},
},
},
},
},
},
}
Expect(ParseDocument(source)).To(MatchDocument(expected))
})

})

})
Loading

0 comments on commit 5b60e00

Please sign in to comment.