Merge pull request #316 from TUSF/patch-2
Fix Quote Block comments, fiddled with Markdown
Cette révision appartient à :
révision
74e649cef3
2 fichiers modifiés avec 36 ajouts et 2 suppressions
|
@ -347,3 +347,12 @@ footer {
|
|||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* Psuedo green-text fuckery. */
|
||||
#comments blockquote {
|
||||
color: #789922;
|
||||
}
|
||||
#comments blockquote:before {
|
||||
content: ">";
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Référencer dans un nouveau ticket