mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Merge pull request #188 from karelbilek/fix-nested-codeblock-empty
Fix empty line detection in markdown in list
This commit is contained in:
commit
75d8cce5b7
3 changed files with 92 additions and 0 deletions
|
|
@ -235,3 +235,91 @@ bbb
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
17: fenced code block in list, empty line, spaces on start
|
||||||
|
//- - - - - - - - -//
|
||||||
|
* foo
|
||||||
|
```Makefile
|
||||||
|
foo
|
||||||
|
|
||||||
|
foo
|
||||||
|
```
|
||||||
|
//- - - - - - - - -//
|
||||||
|
<ul>
|
||||||
|
<li>foo
|
||||||
|
<pre><code class="language-Makefile">foo
|
||||||
|
|
||||||
|
foo
|
||||||
|
</code></pre>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
18: fenced code block in list, empty line, no spaces on start
|
||||||
|
//- - - - - - - - -//
|
||||||
|
* foo
|
||||||
|
```Makefile
|
||||||
|
foo
|
||||||
|
|
||||||
|
foo
|
||||||
|
```
|
||||||
|
//- - - - - - - - -//
|
||||||
|
<ul>
|
||||||
|
<li>foo
|
||||||
|
<pre><code class="language-Makefile">foo
|
||||||
|
|
||||||
|
foo
|
||||||
|
</code></pre>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
|
||||||
|
19: fenced code block inside nested list, empty line, spaces on 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>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
|
||||||
|
20: fenced code block inside nested list, empty line, no space on 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>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
if node.ChildCount() == 1 && node.LastChild().ChildCount() == 0 {
|
||||||
return Close
|
return Close
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reader.Advance(len(line)-1)
|
||||||
return Continue | HasChildren
|
return Continue | HasChildren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
func (b *listItemParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
|
||||||
line, _ := reader.PeekLine()
|
line, _ := reader.PeekLine()
|
||||||
if util.IsBlank(line) {
|
if util.IsBlank(line) {
|
||||||
|
reader.Advance(len(line)-1)
|
||||||
|
|
||||||
return Continue | HasChildren
|
return Continue | HasChildren
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue