Skip to content

Commit

Permalink
feat(parser/renderer): list item continuation (#53)
Browse files Browse the repository at this point in the history
Also, rename test variables for "homogeneousness"

Signed-off-by: Xavier Coulon <[email protected]>
  • Loading branch information
xcoulon authored Feb 16, 2018
1 parent cac6b6d commit 613a112
Show file tree
Hide file tree
Showing 36 changed files with 1,620 additions and 1,168 deletions.
14 changes: 11 additions & 3 deletions parser/asciidoc-grammar.peg
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,17 @@ HorizontalLayout <- "[horizontal]" {
return map[string]interface{}{"layout": "horizontal"}, nil
}

ListParagraph <- lines:(!(UnorderedListItemPrefix) !(LabeledListItemTerm LabeledListItemSeparator) InlineContent EOL)+ {
ListParagraph <- lines:(!(ListItemContinuation) !(UnorderedListItemPrefix) !(LabeledListItemTerm LabeledListItemSeparator) InlineContent EOL)+ {
return types.NewListParagraph(lines.([]interface{}))
}

ListItemContinuation <- "+" WS* NEWLINE {
return types.NewListItemContinuation()
}

ContinuedBlockElement <- ListItemContinuation element:BlockElement {
return element, nil
}

// ------------------------------------------
// Unordered Lists
Expand All @@ -241,11 +248,12 @@ UnorderedListItemPrefix <- WS* level:("*"+ / "-") WS+ { // ignore whitespaces, o
return level, nil
}

UnorderedListItemContent <- elements:(ListParagraph)+ { // Another list or a literal paragraph immediately following a list item will be implicitly included in the list item
UnorderedListItemContent <- elements:(ListParagraph+ ContinuedBlockElement*) { // Another list or a literal paragraph immediately following a list item will be implicitly included in the list item
return types.NewListItemContent(elements.([]interface{}))
}



// ------------------------------------------
// Labeled Lists
// ------------------------------------------
Expand All @@ -270,7 +278,7 @@ LabeledListItemWithDescription <- term:(LabeledListItemTerm) LabeledListItemSepa
return types.NewLabeledListItem(term.([]interface{}), description.([]types.DocElement))
}

LabeledListItemDescription <- elements:(ListParagraph)* {
LabeledListItemDescription <- elements:(ListParagraph / ContinuedBlockElement)* {
return types.NewListItemContent(elements.([]interface{}))
}

Expand Down
Loading

0 comments on commit 613a112

Please sign in to comment.