Skip to content

Commit

Permalink
Fix empty line detection in markdown in list
Browse files Browse the repository at this point in the history
Fix for independent issue in #177
  • Loading branch information
Karel Bilek committed Jan 29, 2021
1 parent 6c741ae commit 5827b8b
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
88 changes: 88 additions & 0 deletions _test/extra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,91 @@ bbb
<img src="gt.jpg" alt="&gt;" />
<img src="amp.jpg" alt="&amp;" /></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//

16: fenced code block in list, empty line
//- - - - - - - - -//
* foo
```Makefile
foo

foo
```
//- - - - - - - - -//
<ul>
<li>foo
<pre><code class="language-Makefile">foo

foo
</code></pre>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//

17: fenced code block in list, empty line, no start
//- - - - - - - - -//
* foo
```Makefile
foo

foo
```
//- - - - - - - - -//
<ul>
<li>foo
<pre><code class="language-Makefile">foo

foo
</code></pre>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//


18: fenced code block inside nested list, empty line
//- - - - - - - - -//
* foo
- bar
```Makefile
foo

foo
```
//- - - - - - - - -//
<ul>
<li>foo
<ul>
<li>bar
<pre><code class="language-Makefile">foo

foo
</code></pre>
</li>
</ul>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//


19: fenced code block inside nested list, empty line no start
//- - - - - - - - -//
* foo
- bar
```Makefile
foo

foo
```
//- - - - - - - - -//
<ul>
<li>foo
<ul>
<li>bar
<pre><code class="language-Makefile">foo

foo
</code></pre>
</li>
</ul>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//
2 changes: 2 additions & 0 deletions parser/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
if node.ChildCount() == 1 && node.LastChild().ChildCount() == 0 {
return Close
}

reader.Advance(len(line)-1)
return Continue | HasChildren
}

Expand Down
2 changes: 2 additions & 0 deletions parser/list_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ func (b *listItemParser) Open(parent ast.Node, reader text.Reader, pc Context) (
func (b *listItemParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
line, _ := reader.PeekLine()
if util.IsBlank(line) {
reader.Advance(len(line)-1)

return Continue | HasChildren
}

Expand Down

0 comments on commit 5827b8b

Please sign in to comment.