Skip to content

Commit 39cb1ac

Browse files
authored
Merge pull request #2043 from lunny/lunny/fix_markdown_render_list
Fix markdown rendering (#1530)
2 parents 5f212ff + 58dcbaf commit 39cb1ac

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

modules/markdown/markdown.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,14 @@ func (r *Renderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
156156
switch {
157157
case bytes.HasPrefix(text, []byte(prefix+"[ ] ")):
158158
text = append([]byte(`<div class="ui fitted disabled checkbox"><input type="checkbox" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
159+
if prefix != "" {
160+
text = bytes.Replace(text, []byte(prefix), []byte{}, 1)
161+
}
159162
case bytes.HasPrefix(text, []byte(prefix+"[x] ")):
160163
text = append([]byte(`<div class="ui checked fitted disabled checkbox"><input type="checkbox" checked="" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
161-
}
162-
if prefix != "" {
163-
text = bytes.Replace(text, []byte("</p>"), []byte{}, 1)
164+
if prefix != "" {
165+
text = bytes.Replace(text, []byte(prefix), []byte{}, 1)
166+
}
164167
}
165168
r.Renderer.ListItem(out, text, flags)
166169
}
@@ -638,10 +641,8 @@ OUTER_LOOP:
638641
// Copy the token to the output verbatim
639642
buf.Write(RenderShortLinks([]byte(token.String()), urlPrefix, true, isWikiMarkdown))
640643

641-
if token.Type == html.StartTagToken {
642-
if !com.IsSliceContainsStr(noEndTags, token.Data) {
643-
stackNum++
644-
}
644+
if token.Type == html.StartTagToken && !com.IsSliceContainsStr(noEndTags, token.Data) {
645+
stackNum++
645646
}
646647

647648
// If this is the close tag to the outer-most, we are done
@@ -656,8 +657,8 @@ OUTER_LOOP:
656657
continue OUTER_LOOP
657658
}
658659

659-
if !com.IsSliceContainsStr(noEndTags, token.Data) {
660-
startTags = append(startTags, token.Data)
660+
if !com.IsSliceContainsStr(noEndTags, tagName) {
661+
startTags = append(startTags, tagName)
661662
}
662663

663664
case html.EndTagToken:

0 commit comments

Comments
 (0)