diff options
Diffstat (limited to 'tpl')
-rw-r--r-- | tpl/transform/transform.go | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/tpl/transform/transform.go b/tpl/transform/transform.go index 42e36eb0f..2aa0c1959 100644 --- a/tpl/transform/transform.go +++ b/tpl/transform/transform.go @@ -15,7 +15,6 @@ package transform import ( - "bytes" "html" "html/template" @@ -91,12 +90,6 @@ func (ns *Namespace) HTMLUnescape(s interface{}) (string, error) { return html.UnescapeString(ss), nil } -var ( - markdownTrimPrefix = []byte("<p>") - markdownTrimSuffix = []byte("</p>\n") - markdownParagraphIndicator = []byte("<p") -) - // Markdownify renders a given input from Markdown to HTML. func (ns *Namespace) Markdownify(s interface{}) (template.HTML, error) { ss, err := cast.ToStringE(s) @@ -114,14 +107,9 @@ func (ns *Namespace) Markdownify(s interface{}) (template.HTML, error) { ) // Strip if this is a short inline type of text. - first := bytes.Index(m, markdownParagraphIndicator) - last := bytes.LastIndex(m, markdownParagraphIndicator) - if first == last { - m = bytes.TrimPrefix(m, markdownTrimPrefix) - m = bytes.TrimSuffix(m, markdownTrimSuffix) - } + m = ns.deps.ContentSpec.TrimShortHTML(m) - return template.HTML(m), nil + return helpers.BytesToHTML(m), nil } // Plainify returns a copy of s with all HTML tags removed. |