Skip to content

Commit

Permalink
feat(parser/renderer): support checklists (#262)
Browse files Browse the repository at this point in the history
fixes #244

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Jan 6, 2019
1 parent 3b97140 commit 34598af
Show file tree
Hide file tree
Showing 10 changed files with 9,890 additions and 9,215 deletions.
12 changes: 10 additions & 2 deletions pkg/parser/asciidoc-grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ OrderedListItemContent <- elements:(ListParagraph+ ContinuedDocumentElement*) {
// ------------------------------------------
// Unordered List Items
// ------------------------------------------
UnorderedListItem <- prefix:(UnorderedListItemPrefix) content:(UnorderedListItemContent) BlankLine* {
return types.NewUnorderedListItem(prefix.(types.UnorderedListItemPrefix), content.([]interface{}))
UnorderedListItem <- prefix:(UnorderedListItemPrefix) checkstyle:(UnorderedListItemCheckStyle)? content:(UnorderedListItemContent) BlankLine* {
return types.NewUnorderedListItem(prefix.(types.UnorderedListItemPrefix), checkstyle, content.([]interface{}))
}

UnorderedListItemPrefix <-
Expand All @@ -553,6 +553,14 @@ UnorderedListItemPrefix <-
return prefix, nil
}

UnorderedListItemCheckStyle <- &"[" style:(
"[ ]" { return types.Unchecked, nil }
/ "[*]" { return types.Checked, nil }
/ "[x]" { return types.Checked, nil }
) WS+ {
return style, nil
}

UnorderedListItemContent <- elements:(ListParagraph+ ContinuedDocumentElement*) { // Another list or a literal paragraph immediately following a list item will be implicitly included in the list item
return types.NewListItemContent(elements.([]interface{}))
}
Expand Down
18,513 changes: 9,323 additions & 9,190 deletions pkg/parser/asciidoc_parser.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions pkg/parser/delimited_block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ with *bold content*
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down Expand Up @@ -749,6 +750,7 @@ ____
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.Dash,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand All @@ -766,6 +768,7 @@ ____
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.Dash,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand All @@ -783,6 +786,7 @@ ____
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.Dash,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down Expand Up @@ -854,6 +858,7 @@ ____`
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down Expand Up @@ -893,6 +898,7 @@ ____`
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down Expand Up @@ -938,6 +944,7 @@ ____`
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand All @@ -955,6 +962,7 @@ ____`
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand All @@ -972,6 +980,7 @@ ____`
Attributes: types.ElementAttributes{},
Level: 1,
BulletStyle: types.OneAsterisk,
CheckStyle: types.NoCheck,
Elements: []interface{}{
types.Paragraph{
Attributes: types.ElementAttributes{},
Expand Down
Loading

0 comments on commit 34598af

Please sign in to comment.