Nested shortcode - how to render mixed content

Hello,

After some search I’m having an headache on how to migrate a shortcode which was working on 0.58 to 0.60+

My use case is the following. I’m using the project reveal-hugo which integrates slides framework RevealJS into Hugo.

On top of this project I’ve added a theme in which I’ve defined some shortcode.

One of them is split which takes a parameter cols which represents the number of columns. Its use case is only for adding div to split the RevealJS slide in columns.

Shortcode code is :

<div {{ with .Get "cols" }}class='split{{ . }}' {{ end }}>
    {{ .Inner |markdownify }}
</div>

Using hugo 0.58 and blackfriday this was working :

{{% split cols="2" %}}
{{< figure src="assets/hugo-logo-wide.svg" >}}
{{% /split %}}
{{% split cols="2" %}}
# Split col2

Content col2 with *italic*
{{% /split %}}

After some tests I came to conclusion I was not using correctly shortcodes because {{% means inner content was markdown to render. But it was working… (even mixed content I discuss bellow)

Now all non markdown content are ignored which is the case for the figure shortcode.

So if I write this instead :

{{< split cols="2" >}}
{{< figure src="assets/hugo-logo-wide.svg" >}}
{{< /split >}}
{{< split cols="2" >}}
# Split col2

Content col2 with *italic*
{{< /split >}}

But here the figure shortcode is not rendered because markdownify ignores it because it has already been rendered as html.

So on nested shortcode I can trick with .Parent.Scratch and indicate to split if inner content is html or markdown. In case of shortcode I don’t manage I’ve added a parameter noMarkdown.

But I cannot mix content shortcode + markdown.

Example :

{{< split cols="2" >}}
# A title

Some markdown content before **shortcode**
{{< figure src="assets/hugo-logo-wide.svg" >}}
{{< /split >}}
{{< split cols="2" >}}
# Split col2

Content col2 with *italic*
{{< /split >}}

I’ve a specific shortcode picto which allowes to add font-awesome picto in content :

{{- if .IsNamedParams -}}
<i class="{{ with .Get "style-prefix" }}{{.}}{{else}}fas{{end}} {{ .Get "name" }} {{ with .Get "class" }}{{.}}{{ end }}"></i>
{{- else -}}
<i class="{{ with .Get 1 }}{{.}}{{else}}fas{{end}} {{ .Get 0 }} {{ with .Get 2 }}{{.}}{{end}}"></i>
{{- end -}}

So I can’t use it any more in my markdown content which are embeded in split shortcode.

Is there a tip for this use case I’ve not seen ? I read things in progress with .RenderString or shortcodify (i’m not sure the status of this one).

Thank you :slight_smile: