I am working on a content transformer (another one) for my hugo template.
I was building the transformer using regex101.com. That awesome site to work with regexp.
This is the regex I am working on: regex101: build, test, and debug regex
I am using this code in the transformer on the content partial
{{ $content = replaceRE $content "(?s)\x60\x60\x60ad-([^\n]*)\ntitle:([^\n]*)\n([^\x60]*)\x60\x60\x60" "{{% ad $1 \"$2\" %}}$3 {{% /ad %}}" }}
The error it is reporting is below. It’s strange that I’ve been able to use raw Go regex using the code generator just joining all the lines into one and using \n instead of linebreaks.
Start building sites …
hugo v0.85.0+extended linux/amd64 BuildDate=unknown
ERROR 2021/07/29 15:03:12 render of "page" failed: execute of template failed: template: _default/single.html:163:11: executing "_default/single.html" at <partialCached "content.html" . .Permalink>: error calling partialCached: "/home/lucasew/WORKSPACE/zettel-hugo/themes/kb/layouts/partials/content.html:39:14": execute of template failed: template: partials/content.html:39:14: executing "partials/content.html" at <replaceRE $content "(?s)\x60\x60\x60ad-([^\n]*)\ntitle:([^\n]*)\n([^\x60]*)\x60\x60\x60" "{{% ad $1 \"$2\" %}}$3 {{% /ad %}}">: error calling replaceRE: error parsing regexp: invalid nested repetition operator: `++`
ERROR 2021/07/29 15:03:12 render of "page" failed: execute of template failed: template: _default/single.html:163:11: executing "_default/single.html" at <partialCached "content.html" . .Permalink>: error calling partialCached: "/home/lucasew/WORKSPACE/zettel-hugo/themes/kb/layouts/partials/content.html:39:14": execute of template failed: template: partials/content.html:39:14: executing "partials/content.html" at <replaceRE $content "(?s)\x60\x60\x60ad-([^\n]*)\ntitle:([^\n]*)\n([^\x60]*)\x60\x60\x60" "{{% ad $1 \"$2\" %}}$3 {{% /ad %}}">: error calling replaceRE: error parsing regexp: invalid escape sequence: `\e`
ERROR 2021/07/29 15:03:12 render of "page" failed: execute of template failed: template: _default/single.html:163:11: executing "_default/single.html" at <partialCached "content.html" . .Permalink>: error calling partialCached: "/home/lucasew/WORKSPACE/zettel-hugo/themes/kb/layouts/partials/content.html:39:14": execute of template failed: template: partials/content.html:39:14: executing "partials/content.html" at <replaceRE $content "(?s)\x60\x60\x60ad-([^\n]*)\ntitle:([^\n]*)\n([^\x60]*)\x60\x60\x60" "{{% ad $1 \"$2\" %}}$3 {{% /ad %}}">: error calling replaceRE: error parsing regexp: invalid escape sequence: `\e`
ERROR 2021/07/29 15:03:12 render of "page" failed: execute of template failed: template: _default/single.html:163:11: executing "_default/single.html" at <partialCached "content.html" . .Permalink>: error calling partialCached: "/home/lucasew/WORKSPACE/zettel-hugo/themes/kb/layouts/partials/content.html:39:14": execute of template failed: template: partials/content.html:39:14: executing "partials/content.html" at <replaceRE $content "(?s)\x60\x60\x60ad-([^\n]*)\ntitle:([^\n]*)\n([^\x60]*)\x60\x60\x60" "{{% ad $1 \"$2\" %}}$3 {{% /ad %}}">: error calling replaceRE: error parsing regexp: invalid escape sequence: `\e`
Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: _default/single.html:163:11: executing "_default/single.html" at <partialCached "content.html" . .Permalink>: error calling partialCached: "/home/lucasew/WORKSPACE/zettel-hugo/themes/kb/layouts/partials/content.html:39:14": execute of template failed: template: partials/content.html:39:14: executing "partials/content.html" at <replaceRE $content "(?s)\x60\x60\x60ad-([^\n]*)\ntitle:([^\n]*)\n([^\x60]*)\x60\x60\x60" "{{% ad $1 \"$2\" %}}$3 {{% /ad %}}">: error calling replaceRE: error parsing regexp: invalid nested repetition operator: `**`
Built in 9249 ms
It seems to detect some kind of loop that is under control here because I setup to match all characters except one that is the stop criteria.