From 4a22cf2ef9fbd139a02fe9a664b437e09c179ed2 Mon Sep 17 00:00:00 2001 From: Florian Schlachter Date: Wed, 1 Oct 2014 22:12:33 +0200 Subject: [PATCH] It's not necessary anymore to apply the 'safe'-filter on markdown-filters. --- README.md | 2 +- filters.go | 2 +- filters_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5c58bb0..c975351 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ All additional filters/tags will be registered automatically. - **truncatesentences** / **truncatesentences_html** (returns the first X sentences [like truncatechars/truncatewords]; please provide X as a parameter) - Markup - - **markdown** (parses markdown text and outputs HTML; **hint**: use the **safe**-filter to make the output not being escaped) + - **markdown** - Humanize - **[intcomma](https://docs.djangoproject.com/en/dev/ref/contrib/humanize/#intcomma)** (put decimal marks into the number) diff --git a/filters.go b/filters.go index e7e0a9b..d08e934 100644 --- a/filters.go +++ b/filters.go @@ -36,7 +36,7 @@ func init() { } func filterMarkdown(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, error) { - return pongo2.AsValue(string(blackfriday.MarkdownCommon([]byte(in.String())))), nil + return pongo2.AsSafeValue(string(blackfriday.MarkdownCommon([]byte(in.String())))), nil } func filterSlugify(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, error) { diff --git a/filters_test.go b/filters_test.go index 4a511f6..30db2ba 100644 --- a/filters_test.go +++ b/filters_test.go @@ -20,7 +20,7 @@ var _ = Suite(&TestSuite1{}) func (s *TestSuite1) TestFilters(c *C) { // Markdown - c.Assert(pongo2.RenderTemplateString("{{ \"**test**\"|markdown|safe }}", nil), Equals, "

test

\n") + c.Assert(pongo2.RenderTemplateString("{{ \"**test**\"|markdown }}", nil), Equals, "

test

\n") // Slugify c.Assert(pongo2.RenderTemplateString("{{ \"this is รค test!\"|slugify }}", nil), Equals, "this-is-a-test")