This commit is contained in:
yuin 2021-10-17 19:21:23 +09:00
parent e77ca9231a
commit 829dc0ae24
3 changed files with 29 additions and 9 deletions

View file

@ -565,8 +565,21 @@ x
44: An empty list item(with trailing spaces) cannot interrupt a paragraph
//- - - - - - - - -//
a\n* \n
a
*
//- - - - - - - - -//
<p>a
*</p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
45: Multiple empty list items
//- - - - - - - - -//
-
-
//- - - - - - - - -//
<ul>
<li></li>
<li></li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//

View file

@ -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
}

View file

@ -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
}