diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-05-29 16:41:57 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-05-30 11:32:55 +0200 |
commit | 9e904d756be02ca30e4cd9abb1eae8ba01f9c8af (patch) | |
tree | 8771585a9031e37f8ee16044b507af5eb7506083 /common | |
parent | d2cfaede5be420c7d8b701d97b98bc61b87e46d5 (diff) | |
download | hugo-9e904d756be02ca30e4cd9abb1eae8ba01f9c8af.tar.gz hugo-9e904d756be02ca30e4cd9abb1eae8ba01f9c8af.zip |
Make .RenderString render shortcodes
Fixes #6703
Diffstat (limited to 'common')
-rw-r--r-- | common/text/transform.go | 5 | ||||
-rw-r--r-- | common/text/transform_test.go | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/common/text/transform.go b/common/text/transform.go index 2b05b9b4f..de093af0d 100644 --- a/common/text/transform.go +++ b/common/text/transform.go @@ -64,11 +64,12 @@ func Puts(s string) string { // VisitLinesAfter calls the given function for each line, including newlines, in the given string. func VisitLinesAfter(s string, fn func(line string)) { - high := strings.Index(s, "\n") + high := strings.IndexRune(s, '\n') for high != -1 { fn(s[:high+1]) s = s[high+1:] - high = strings.Index(s, "\n") + + high = strings.IndexRune(s, '\n') } if s != "" { diff --git a/common/text/transform_test.go b/common/text/transform_test.go index 10738aee7..41447715f 100644 --- a/common/text/transform_test.go +++ b/common/text/transform_test.go @@ -59,3 +59,18 @@ line 3` c.Assert(collected, qt.DeepEquals, []string{"line 1\n", "line 2\n", "\n", "line 3"}) } + +func BenchmarkVisitLinesAfter(b *testing.B) { + const lines = `line 1 + line 2 + + line 3` + + for i := 0; i < b.N; i++ { + VisitLinesAfter(lines, func(s string) { + + }) + + } + +} |