diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-05-25 10:56:14 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-05-25 17:55:23 +0200 |
commit | 3854a6fa6c323d1c09aa71a0626c9eef62709294 (patch) | |
tree | ea3727c14f73fb73aef89d43795dd6d6f75f1220 /tpl/internal | |
parent | cd0112a05a9ddb7043c9808284f93d8099c48473 (diff) |
Fix Plainify edge cases
This commit replaces the main part of `helpers.StripHTML` with Go's implementation in its html/template package.
It's a little slower, but correctness is more important:
```bash
BenchmarkStripHTMLOld-10 680316 1764 ns/op 728 B/op 4 allocs/op
BenchmarkStripHTMLNew-10 384520 3099 ns/op 2089 B/op 10 allocs/op
```
Fixes #9199
Fixes #9909
Closes #9410
Diffstat (limited to 'tpl/internal')
-rw-r--r-- | tpl/internal/go_templates/htmltemplate/hugo_template.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tpl/internal/go_templates/htmltemplate/hugo_template.go b/tpl/internal/go_templates/htmltemplate/hugo_template.go index eba54fbbf..99edf8f68 100644 --- a/tpl/internal/go_templates/htmltemplate/hugo_template.go +++ b/tpl/internal/go_templates/htmltemplate/hugo_template.go @@ -34,3 +34,8 @@ func (t *Template) Prepare() (*template.Template, error) { } return t.text, nil } + +// See https://github.com/golang/go/issues/5884 +func StripTags(html string) string { + return stripTags(html) +} |