That works with Hugo 0.99.1 without any issues and creates an output like:
In current 0.100.0 I get errors like:
Error:
Error building site: "/path/content/Divers/Readme.md:140:1":
failed to render shortcode "ghsvs/callout":
failed to process shortcode:
"/path/layouts/shortcodes/ghsvs/callout.html:x:13":
execute of template failed:
template: shortcodes/ghsvs/callout.html:x:13:
executing "shortcodes/ghsvs/callout.html" at <$.Page.RenderString>:
error calling RenderString: "/path/content/Divers/Readme.md:2:209":
got closing shortcode, but none is open
In Hugo 0.100.0 we added support for shortcodes in RenderString (a long sought after feature). RenderString was never meant to be used on the .Inner content of a shortcode, and it willl certainly not work that great now, as you have experienced.
OK, bad news and I have to exchange again my content system for ducumentations.
Just to be said:
I have read all comments on GitHub yesterday concerning “support for shortcodes in RenderString” and still I don’t understand what is supported where and why and what are the benefits in which case. I just see an unsolvable, grave B\C break and that RenderString is no longer supported inside my shortcodes which was the case in the past. How shall ““creative”” users know “what was never meant” for this or that?
I’m sorry that your site broke. But it’s very hard to predict how thousands of users will use a certain function. The documentation is geared towards how and when to use certain features, not so much when not to use a certain function, and I’m not sure that is practical. But we surely have potential for improvements in that area (and that is being worked on).
Note that I’m pretty sure it’s possible to rewrite that code that fails for you, which I suspect will take less time than porting your site to another software.
Same problem when using markdownify
…
{{ .Inner | Markdownify }}
…
But no solution is gfound?
Also good in 99.1 but not more in 100.0
Blocking hugo on version 99 is the only possibility I see.
Awaiting solution.
Not the first time I need to rewrite some files due to hugo update
I think the statement of bep is clear. There won’t be an universal solution. Maybe if you pay him for one
{{ .Inner | $.Page.RenderString }}
does not fail in all contexts. In my case it depends on which nested shortcode I use.
Therefore (and because my “company partners” where nagging that I again want to change the system ) I have added an additional and optional boolean parameter and my main shortcode looka now like this:
{{- /*
- Usage: `callout "type"`[false], where `type` is one of info (default), danger, or warning.
- @since Hugo 100.0 this shortcode crashes if a < ghsvs/code > is embedded.
- therefore parameter markdownify was introduced, which must be explicitly set to false to bypass $.Page.RenderString.
*/ -}}
{{- $css_class := .Get 0 | default "info" -}}
{{- $markdownify := .Get 1 | default true -}}
<div class="bd-callout bd-callout-{{ $css_class }}">
{{- if $markdownify -}}
{{ .Inner | $.Page.RenderString }}
{{- else -}}
{{ .Inner }}
{{- end -}}
</div>
In cases where the rendered result looks “weird” there is now a simplified second shortcode and my “company partners” have to live with the discomfort to restructure their content (sometimes)
“”“Creativity”“” rules! (…and the result is sometimes more exhausting.)