Cannot mix shortcodes and markdown within a shortcode

I’m trying to use a mix of markdown and nested shortcodes and I cannot get the combination to work at the same level. I’ve concocted a trivial example, although this is not my exact use case, it demostrates the problem. Given the following shortcodes:


{{ .Inner }}


{{ .Inner | markdownify }}


<span class="label">{{ .Get 0 }}</span>

In the example situation

{{< nothing >}}
## Header 1
{{< label "A label" >}}
{{< /nothing >}}

generates the following:

## Header 1
<span class="label">A label</span>

which is not correctly translating the markdown header. So, if I use the shortcode to markdownify the content:

{{< markdown >}}
## Header 2
{{< label "A label" >}}
{{< /markdown >}}


<h2><a class="anchor" id="header-2"></a>Header 2</h2>
<p><!-- raw HTML omitted -->A label<!-- raw HTML omitted -->

so now the label shortcode is not generated correctly. If I used the % tags instead of the < in the above examples, e.g.:

{{% nothing %}}
## Header 3
{{< label "A label" >}}
{{% /nothing %}}
{{% markdown %}}
## Header 4
{{< label "A label" >}}
{{% /markdown %}}

I get the following:

<h2><a class="anchor" id="header-3"></a>Header 3</h2>
<p><!-- raw HTML omitted -->A label<!-- raw HTML omitted --></p>
<!-- raw HTML omitted -->

So it seems that I simply can’t use shortcodes and markdown at the same level within a shortcode. This is particularly a problem for me, since I used a shortcode to indicate a “section”, and within that I have a markdown table… inside the table cells, I’m trying to use shortcode for images. This completely breaks.

I found this question previously, however, the asker did not respond to @bep suggestion. I hope this example demonstrates @bep suggestion does not work either - unless I’ve missed something.

I would seem like the .RenderString could be the answer to our problem here, so we could replace the markdownify with .RenderString but this doesn’t work for shortcodes (

My actual use case is pretty much exactly @bric3 example in the github issue:

Any help is appreciated!


I believe that both of these issues need to be resolved in order to achieve what you want:

1 Like

Thanks, I wasn’t aware of the unclosed <p> tag, but now I see it in my snippets above - thanks!

As a work around to this issue, I’ve enabled markup.goldmark.renderer.unsafe=true.

I found the problem with using .RenderString was that the nested shortcode was being converted first, thus in actual fact the code was passing markdown and HTML to Goldmark (via the RenderString function), not markdown and shortcodes… so Goldmark was throwing away the HTML.