Note that this is a Markdownify filter, and is named as such; it's not a Asccidoc filter or in any way connected to a Page.
Fixes #524
"isset": IsSet,
"echoParam": ReturnWhenSet,
"safeHtml": SafeHtml,
+ "markdownify": Markdownify,
"first": First,
"where": Where,
"highlight": Highlight,
return template.HTML(helpers.Highlight(html.UnescapeString(str), lang))
}
+func Markdownify(text string) template.HTML {
+ return template.HTML(helpers.RenderBytes([]byte(text), "markdown", ""))
+}
+
func SafeHtml(text string) template.HTML {
return template.HTML(text)
}
package tpl
import (
+ "html/template"
"reflect"
"testing"
)
}
}
}
+
+func TestMarkdownify(t *testing.T) {
+
+ result := Markdownify("Hello **World!**")
+
+ expect := template.HTML("<p>Hello <strong>World!</strong></p>\n")
+
+ if result != expect {
+ t.Errorf("Markdownify: got '%s', expected '%s'", result, expect)
+ }
+}