diff --git a/_test/extra.txt b/_test/extra.txt index f4baf84..e4e3a9f 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -565,8 +565,21 @@ x 44: An empty list item(with trailing spaces) cannot interrupt a paragraph //- - - - - - - - -// -a\n* \n +a +* //- - - - - - - - -//

a *

//= = = = = = = = = = = = = = = = = = = = = = = =// + +45: Multiple empty list items +//- - - - - - - - -// +- + +- +//- - - - - - - - -// + +//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/parser/list.go b/parser/list.go index 5be0747..d6ebbfc 100644 --- a/parser/list.go +++ b/parser/list.go @@ -160,14 +160,18 @@ func (b *listParser) Open(parent ast.Node, reader text.Reader, pc Context) (ast. func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) State { list := node.(*ast.List) line, _ := reader.PeekLine() - if util.IsBlank(line) { - // A list item can begin with at most one blank line - if node.ChildCount() == 1 && node.LastChild().ChildCount() == 0 { - return Close + startsWithBlankLines := util.IsBlank(line) + if startsWithBlankLines { + if node.LastChild().ChildCount() != 0 { + return Continue | HasChildren + } + for { + reader.AdvanceLine() + line, _ = reader.PeekLine() + if !util.IsBlank(line) { + break + } } - - reader.Advance(len(line) - 1) - return Continue | HasChildren } // "offset" means a width that bar indicates. @@ -209,6 +213,9 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta } return Close } + if startsWithBlankLines { + return Close + } return Continue | HasChildren } diff --git a/parser/list_item.go b/parser/list_item.go index e29b0a4..4873bf4 100644 --- a/parser/list_item.go +++ b/parser/list_item.go @@ -40,7 +40,7 @@ func (b *listItemParser) Open(parent ast.Node, reader text.Reader, pc Context) ( } itemOffset := calcListOffset(line, match) node := ast.NewListItem(match[3] + itemOffset) - if match[4] < 0 || match[5]-match[4] == 1 { + if match[4] < 0 || util.IsBlank(line[match[4]:match[5]]) { return node, NoChildren }