qtya
April 22, 2024, 3:43pm
1
I created a shortcode like so:
<p>{{ .Inner }}</p>
This
{{< myshortcode >}}
**text**
{{< /myshortcode >}}
Literally renders text without Markdown formatting as expected.
However
{{% myshortcode %}}
**text**
{{% /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?
Thanks!
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:
https://spec.commonmark.org/0.31.2/#html-blocks
I think you want to do this instead:
<p>{{ .Inner | .Page.RenderString }}</p>
and call it with:
{{< myshortcode >}}
**text**
{{< /myshortcode >}}
1 Like
qtya
April 23, 2024, 8:02am
3
This works, thank you so much!
system
Closed
April 25, 2024, 8:02am
4
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.