Nested shortcodes and markdownify

I have a shortcode to display an “alert” block which looks like this

{{- $title := .Get 0 -}}
<div class="alert alert-info" role="alert">
  <h5 class="alert-heading fw-bold">{{ $title }}</h5>
  {{- .Inner | markdownify -}}
</div>

It works fine, but in some cases I want to show an image (for example with standard figure shortcode) inside an alert block. Unfortunately this does not work, the image is not shown. I can make image appear by removing markdownify but this breaks all formatting of the alert text.

From what I understand, nested shortcodes are supported by Hugo but there is no way to handle shortcodes when applying markdownify to the inner text. I found similar question here but it does not have a solution. Am I righ that right now there is no way to achieve what I want?

When you view source in your browser (Ctrl + U) do you see <!-- raw HTML omitted --> anywhere?

Yes, there is <!-- raw HTML omitted --> inside alert code. My understanding is that this ommited code is HTML generated by the nested figure shortcode.

Search this forum for “raw HTML omitted”

Thanks for the pointer! So the only way to workaround this is to enable unsafe for markdown renderer, right?

Which is no problem if you’re the only one writing MD.

1 Like

I understand that from the other discussions here and at GitHub. Just wanted to check that I don’t miss some other workarounds.

Thanks for confirming that this is the only solution for now.

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