Merge pull request #229 from russross/issue-228

Fix bug with gathering list item lines
pull/234/head
Vytautas Šaltenis 2015-12-30 17:42:28 +02:00
commit c8875c0ed4
2 changed files with 53 additions and 8 deletions

View File

@ -1153,6 +1153,7 @@ gatherlines:
// and move on to the next line
if p.isEmpty(data[line:i]) > 0 {
containsBlankLine = true
raw.Write(data[line:i])
line = i
continue
}
@ -1220,17 +1221,10 @@ gatherlines:
// a blank line means this should be parsed as a block
case containsBlankLine:
raw.WriteByte('\n')
*flags |= LIST_ITEM_CONTAINS_BLOCK
}
// if this line was preceeded by one or more blanks,
// re-introduce the blank into the buffer
if containsBlankLine {
containsBlankLine = false
raw.WriteByte('\n')
}
containsBlankLine = false
// add the line into the working buffer without prefix
raw.Write(data[line+indent : i])

View File

@ -702,10 +702,41 @@ func TestUnorderedList(t *testing.T) {
"* List\n\n * sublist\n\n normal text\n\n * another sublist\n",
"<ul>\n<li><p>List</p>\n\n<ul>\n<li>sublist</li>\n</ul>\n\n<p>normal text</p>\n\n<ul>\n<li>another sublist</li>\n</ul></li>\n</ul>\n",
`* Foo
bar
qux
`,
`<ul>
<li><p>Foo</p>
<pre><code>bar
qux
</code></pre></li>
</ul>
`,
}
doTestsBlock(t, tests, 0)
}
func TestFencedCodeBlockWithinList(t *testing.T) {
doTestsBlock(t, []string{
"* Foo\n\n ```\n bar\n\n qux\n ```\n",
`<ul>
<li><p>Foo</p>
<pre><code>bar
qux
</code></pre></li>
</ul>
`,
}, EXTENSION_FENCED_CODE)
}
func TestOrderedList(t *testing.T) {
var tests = []string{
"1. Hello\n",
@ -798,6 +829,26 @@ func TestOrderedList(t *testing.T) {
"1. numbers\n1. are ignored\n",
"<ol>\n<li>numbers</li>\n<li>are ignored</li>\n</ol>\n",
`1. Foo
bar
qux
`,
`<ol>
<li><p>Foo</p>
<pre><code>bar
qux
</code></pre></li>
</ol>
`,
}
doTestsBlock(t, tests, 0)
}