Merge pull request #2043 from lunny/lunny/fix_markdown_render_list
Fix markdown rendering (#1530)
This commit is contained in:
commit
39cb1ac517
1 changed files with 10 additions and 9 deletions
|
@ -156,11 +156,14 @@ func (r *Renderer) ListItem(out *bytes.Buffer, text []byte, flags int) {
|
||||||
switch {
|
switch {
|
||||||
case bytes.HasPrefix(text, []byte(prefix+"[ ] ")):
|
case bytes.HasPrefix(text, []byte(prefix+"[ ] ")):
|
||||||
text = append([]byte(`<div class="ui fitted disabled checkbox"><input type="checkbox" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
|
text = append([]byte(`<div class="ui fitted disabled checkbox"><input type="checkbox" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
|
||||||
|
if prefix != "" {
|
||||||
|
text = bytes.Replace(text, []byte(prefix), []byte{}, 1)
|
||||||
|
}
|
||||||
case bytes.HasPrefix(text, []byte(prefix+"[x] ")):
|
case bytes.HasPrefix(text, []byte(prefix+"[x] ")):
|
||||||
text = append([]byte(`<div class="ui checked fitted disabled checkbox"><input type="checkbox" checked="" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
|
text = append([]byte(`<div class="ui checked fitted disabled checkbox"><input type="checkbox" checked="" disabled="disabled" /><label /></div>`), text[3+len(prefix):]...)
|
||||||
}
|
if prefix != "" {
|
||||||
if prefix != "" {
|
text = bytes.Replace(text, []byte(prefix), []byte{}, 1)
|
||||||
text = bytes.Replace(text, []byte("</p>"), []byte{}, 1)
|
}
|
||||||
}
|
}
|
||||||
r.Renderer.ListItem(out, text, flags)
|
r.Renderer.ListItem(out, text, flags)
|
||||||
}
|
}
|
||||||
|
@ -638,10 +641,8 @@ OUTER_LOOP:
|
||||||
// Copy the token to the output verbatim
|
// Copy the token to the output verbatim
|
||||||
buf.Write(RenderShortLinks([]byte(token.String()), urlPrefix, true, isWikiMarkdown))
|
buf.Write(RenderShortLinks([]byte(token.String()), urlPrefix, true, isWikiMarkdown))
|
||||||
|
|
||||||
if token.Type == html.StartTagToken {
|
if token.Type == html.StartTagToken && !com.IsSliceContainsStr(noEndTags, token.Data) {
|
||||||
if !com.IsSliceContainsStr(noEndTags, token.Data) {
|
stackNum++
|
||||||
stackNum++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is the close tag to the outer-most, we are done
|
// If this is the close tag to the outer-most, we are done
|
||||||
|
@ -656,8 +657,8 @@ OUTER_LOOP:
|
||||||
continue OUTER_LOOP
|
continue OUTER_LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
if !com.IsSliceContainsStr(noEndTags, token.Data) {
|
if !com.IsSliceContainsStr(noEndTags, tagName) {
|
||||||
startTags = append(startTags, token.Data)
|
startTags = append(startTags, tagName)
|
||||||
}
|
}
|
||||||
|
|
||||||
case html.EndTagToken:
|
case html.EndTagToken:
|
||||||
|
|
Reference in a new issue