Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Merge pull request #316 from TUSF/patch-2

Fix Quote Block comments, fiddled with Markdown
Cette révision appartient à :
keo 2017-05-11 00:59:48 +03:00 révisé par GitHub
révision 74e649cef3
2 fichiers modifiés avec 36 ajouts et 2 suppressions

Voir le fichier

@ -347,3 +347,12 @@ footer {
max-width: 100%;
height: auto;
}
/* Psuedo green-text fuckery. */
#comments blockquote {
color: #789922;
}
#comments blockquote:before {
content: ">";
}

Voir le fichier

@ -2,14 +2,39 @@ package util
import (
"github.com/microcosm-cc/bluemonday"
"github.com/russross/blackfriday"
md "github.com/russross/blackfriday"
"html/template"
"strings"
)
//Some default rules, plus and minus some.
var mdOptions = 0 |
md.EXTENSION_AUTOLINK |
md.EXTENSION_HARD_LINE_BREAK |
md.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK |
md.EXTENSION_NO_INTRA_EMPHASIS |
md.EXTENSION_SPACE_HEADERS |
md.EXTENSION_STRIKETHROUGH
var htmlFlags = 0 |
md.HTML_USE_XHTML |
md.HTML_SMARTYPANTS_FRACTIONS |
md.HTML_SAFELINK |
md.HTML_NOREFERRER_LINKS |
md.HTML_HREF_TARGET_BLANK
func init() {
HtmlMdRenderer = md.HtmlRenderer(htmlFlags, "", "")
}
var HtmlMdRenderer md.Renderer
// TODO: restrict certain types of markdown
func MarkdownToHTML(markdown string) template.HTML {
unsafe := blackfriday.MarkdownCommon([]byte(markdown))
if len(markdown) >= 3 && markdown[:3] == ">" {
markdown = ">" + markdown[3:]
}
markdown = strings.Replace(markdown,"\n>","\n>", -1)
unsafe := md.MarkdownOptions([]byte(markdown), HtmlMdRenderer, md.Options{Extensions: mdOptions})
html := bluemonday.UGCPolicy().SanitizeBytes(unsafe)
return template.HTML(html)
}