mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
#248 - 8
This commit is contained in:
parent
e77ca9231a
commit
829dc0ae24
3 changed files with 29 additions and 9 deletions
|
|
@ -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>
|
||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||
|
|
|
|||
|
|
@ -160,15 +160,19 @@ 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
|
||||
}
|
||||
|
||||
reader.Advance(len(line) - 1)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "offset" means a width that bar indicates.
|
||||
// - aaaaaaaa
|
||||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue