diff options
author | Morlinest <Morlinest@users.noreply.github.com> | 2017-04-24 06:18:36 +0200 |
---|---|---|
committer | Bo-Yi Wu <appleboy.tw@gmail.com> | 2017-04-24 12:18:36 +0800 |
commit | fcc7cdab112e64c2b158c594c7d46746ff6c46f8 (patch) | |
tree | 26368e323472d28fb65c68eec8b6f735d457b3dd /modules/markdown | |
parent | 5b8fe1e181d80d002bb348ed8a4b152d0d52a726 (diff) | |
download | gitea-fcc7cdab112e64c2b158c594c7d46746ff6c46f8.tar.gz gitea-fcc7cdab112e64c2b158c594c7d46746ff6c46f8.zip |
Fix markdown rendering (#1530)
Diffstat (limited to 'modules/markdown')
-rw-r--r-- | modules/markdown/markdown.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/modules/markdown/markdown.go b/modules/markdown/markdown.go index 183804a9ee..85be5d61de 100644 --- a/modules/markdown/markdown.go +++ b/modules/markdown/markdown.go @@ -145,11 +145,14 @@ func (r *Renderer) ListItem(out *bytes.Buffer, text []byte, flags int) { switch { 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):]...) + if prefix != "" { + text = bytes.Replace(text, []byte(prefix), []byte{}, 1) + } 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):]...) - } - if prefix != "" { - text = bytes.Replace(text, []byte("</p>"), []byte{}, 1) + if prefix != "" { + text = bytes.Replace(text, []byte(prefix), []byte{}, 1) + } } r.Renderer.ListItem(out, text, flags) } @@ -627,10 +630,8 @@ OUTER_LOOP: // Copy the token to the output verbatim buf.Write(RenderShortLinks([]byte(token.String()), urlPrefix, true, isWikiMarkdown)) - if token.Type == html.StartTagToken { - if !com.IsSliceContainsStr(noEndTags, token.Data) { - stackNum++ - } + if token.Type == html.StartTagToken && !com.IsSliceContainsStr(noEndTags, token.Data) { + stackNum++ } // If this is the close tag to the outer-most, we are done @@ -645,8 +646,8 @@ OUTER_LOOP: continue OUTER_LOOP } - if !com.IsSliceContainsStr(noEndTags, token.Data) { - startTags = append(startTags, token.Data) + if !com.IsSliceContainsStr(noEndTags, tagName) { + startTags = append(startTags, tagName) } case html.EndTagToken: |