summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-20 01:52:11 -0500
committerUnknwon <u@gogs.io>2015-11-20 01:52:11 -0500
commit9b6c835715ab27aa7a008a51415f38ca2a856cd0 (patch)
treec5de699a0b3092399210284819a899f228aa2edf /modules
parent902b5784659327a61ba7de56ef1885fcc6549b17 (diff)
downloadgitea-9b6c835715ab27aa7a008a51415f38ca2a856cd0.tar.gz
gitea-9b6c835715ab27aa7a008a51415f38ca2a856cd0.zip
fix #1873
Diffstat (limited to 'modules')
-rw-r--r--modules/base/markdown.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/base/markdown.go b/modules/base/markdown.go
index 1f48b88db7..d55e98dd54 100644
--- a/modules/base/markdown.go
+++ b/modules/base/markdown.go
@@ -231,9 +231,15 @@ func RenderRawMarkdown(body []byte, urlPrefix string) []byte {
return body
}
+var (
+ leftAngleBracket = []byte("</")
+ rightAngleBracket = []byte(">")
+)
+
// PostProcessMarkdown treats different types of HTML differently,
// and only renders special links for plain text blocks.
func PostProcessMarkdown(rawHtml []byte, urlPrefix string) []byte {
+ var startTag string
var buf bytes.Buffer
tokenizer := html.NewTokenizer(bytes.NewReader(rawHtml))
for html.ErrorToken != tokenizer.Next() {
@@ -243,6 +249,7 @@ func PostProcessMarkdown(rawHtml []byte, urlPrefix string) []byte {
buf.Write(RenderSpecialLink([]byte(token.String()), urlPrefix))
case html.StartTagToken:
+ startTag = token.Data
buf.WriteString(token.String())
tagName := token.Data
// If this is an excluded tag, we skip processing all output until a close tag is encountered.
@@ -258,6 +265,10 @@ func PostProcessMarkdown(rawHtml []byte, urlPrefix string) []byte {
}
}
+ case html.EndTagToken:
+ buf.Write(leftAngleBracket)
+ buf.WriteString(startTag)
+ buf.Write(rightAngleBracket)
default:
buf.WriteString(token.String())
}