Custom shortcode not rendering markdown

I created a shortcode like so:

<p>{{ .Inner }}</p>


{{< myshortcode >}}
{{< /myshortcode >}}

Literally renders text without Markdown formatting as expected.


{{% myshortcode %}}
{{% /myshortcode %}}

renders an HTML comment saying <!-- raw HTML omitted -->

If I understand the docs correctly this is how you are supposed to add Markdown to a shortcode. What am I doing wrong?


In your example, when you wrap .Inner in a p element, you are mixing HTML with markdown. The markdown renderer is simply following the (somewhat) complex rules for rendering HTML blocks:

I think you want to do this instead:

<p>{{ .Inner | .Page.RenderString }}</p>

and call it with:

{{< myshortcode >}}
{{< /myshortcode >}}
1 Like

This works, thank you so much!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.