First, your markdown input is not quite right -- headings should have whitespace separating the #
s from the text. You can verify this using blackfriday-tool:
$ echo ##Hello | blackfriday-tool
<p>##Hello</p>
$ echo ## Hello | blackfriday-tool
<h2>Hello</h2>
Second, if you feed the HTML output from blackfriday
into a html/template
, it is going to be automatically escaped for safety.
If you trust the markdown input and blackfriday's HTML output, then you can tell the template system to trust the content by wrapping it in a html/template
HTML
value:
type Page struct {
Content template.HTML
}
err = t.ExecuteTemplate(w, "page", Page{Content: template.HTML(s)})
See http://play.golang.org/p/eO7KDJMlb8 for an example.