Merge pull request #17 from litao91/fixlist

Fix inaccurate indent calculation of list_item and add extra test
This commit is contained in:
Yusuke Inuzuka 2019-07-16 17:24:29 +09:00 committed by GitHub
commit 36e42c4e73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 1 deletions

10
_test/extra.txt Normal file
View file

@ -0,0 +1,10 @@
1
//- - - - - - - - -//
* A
B
//- - - - - - - - -//
<ul>
<li>A
B</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//

15
extra_test.go Normal file
View file

@ -0,0 +1,15 @@
package goldmark
import (
"testing"
"github.com/yuin/goldmark/renderer/html"
)
func TestDefinitionList(t *testing.T) {
markdown := New(WithRendererOptions(
html.WithXHTML(),
html.WithUnsafe(),
))
DoTestCaseFile(markdown, "_test/extra.txt", t)
}

View file

@ -83,7 +83,7 @@ func calcListOffset(source []byte, match [6]int) int {
if util.IsBlank(source[match[4]:]) { // list item starts with a blank line if util.IsBlank(source[match[4]:]) { // list item starts with a blank line
offset = 1 offset = 1
} else { } else {
offset, _ = util.IndentWidth(source[match[4]:], match[2]) offset, _ = util.IndentWidth(source[match[4]:], match[4])
if offset > 4 { // offseted codeblock if offset > 4 { // offseted codeblock
offset = 1 offset = 1
} }