Browse Source

Fix markdown rendering (#1530)

Morlinest 3 years ago
parent
commit
fcc7cdab11
1 changed files with 10 additions and 9 deletions
  1. 10 9
      modules/markdown/markdown.go

+ 10 - 9
modules/markdown/markdown.go

@@ -145,11 +145,14 @@ func (r *Renderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
145 145
 	switch {
146 146
 	case bytes.HasPrefix(text, []byte(prefix+"[ ] ")):
147 147
 		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
+		}
148 151
 	case bytes.HasPrefix(text, []byte(prefix+"[x] ")):
149 152
 		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
+		}
153 156
 	}
154 157
 	r.Renderer.ListItem(out, text, flags)
155 158
 }
@@ -627,10 +630,8 @@ OUTER_LOOP:
627 630
 					// Copy the token to the output verbatim
628 631
 					buf.Write(RenderShortLinks([]byte(token.String()), urlPrefix, true, isWikiMarkdown))
629 632
 
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++
634 635
 					}
635 636
 
636 637
 					// If this is the close tag to the outer-most, we are done
@@ -645,8 +646,8 @@ OUTER_LOOP:
645 646
 				continue OUTER_LOOP
646 647
 			}
647 648
 
648
-			if !com.IsSliceContainsStr(noEndTags, token.Data) {
649
-				startTags = append(startTags, token.Data)
649
+			if !com.IsSliceContainsStr(noEndTags, tagName) {
650
+				startTags = append(startTags, tagName)
650 651
 			}
651 652
 
652 653
 		case html.EndTagToken: