Skip to content

Commit fcc7cda

Browse files
Morlinestappleboy
authored andcommitted
Fix markdown rendering (#1530)
1 parent 5b8fe1e commit fcc7cda

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
@@ -145,11 +145,14 @@ func (r *Renderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
145145
switch {
146146
case bytes.HasPrefix(text, []byte(prefix+"[ ] ")):
147147
text = append([]byte(`<div class="ui fitted disabled checkbox"><input type="checkbox" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
148+
if prefix != "" {
149+
text = bytes.Replace(text, []byte(prefix), []byte{}, 1)
150+
}
148151
case bytes.HasPrefix(text, []byte(prefix+"[x] ")):
149152
text = append([]byte(`<div class="ui checked fitted disabled checkbox"><input type="checkbox" checked="" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
150-
}
151-
if prefix != "" {
152-
text = bytes.Replace(text, []byte("</p>"), []byte{}, 1)
153+
if prefix != "" {
154+
text = bytes.Replace(text, []byte(prefix), []byte{}, 1)
155+
}
153156
}
154157
r.Renderer.ListItem(out, text, flags)
155158
}
@@ -627,10 +630,8 @@ OUTER_LOOP:
627630
// Copy the token to the output verbatim
628631
buf.Write(RenderShortLinks([]byte(token.String()), urlPrefix, true, isUncycloMarkdown))
629632

630-
if token.Type == html.StartTagToken {
631-
if !com.IsSliceContainsStr(noEndTags, token.Data) {
632-
stackNum++
633-
}
633+
if token.Type == html.StartTagToken && !com.IsSliceContainsStr(noEndTags, token.Data) {
634+
stackNum++
634635
}
635636

636637
// If this is the close tag to the outer-most, we are done
@@ -645,8 +646,8 @@ OUTER_LOOP:
645646
continue OUTER_LOOP
646647
}
647648

648-
if !com.IsSliceContainsStr(noEndTags, token.Data) {
649-
startTags = append(startTags, token.Data)
649+
if !com.IsSliceContainsStr(noEndTags, tagName) {
650+
startTags = append(startTags, tagName)
650651
}
651652

652653
case html.EndTagToken:

0 commit comments

Comments
 (0)