Markdown in nested shortcodes

I need nested shortcodes, but I also want to use markdown inside of the shortcodes.
Take the nested shortcode example:

I would something like this:
{{< test/gallery class=“content-gallery” >}}
# Some markdown
and some text
{{< test/img src="/images/one.jpg" >}}
{{< test/img src="/images/two.jpg" >}}
{{< /test/gallery >}}
{{< test/img src="/images/three.jpg" >}}

How can I get the markdown inside of the gallery to render?

Yes, that was the first thing I tried, it unfortunately results in

<div class="“content-gallery”"> <h1 id="some-markdown">Some markdown</h1> <p>and some text <!-- raw HTML omitted --></p> <!-- raw HTML omitted --> </div> <img src="[/images/three.jpg](view-source:http://localhost:1313/images/three.jpg)">

I think there’s this issue for this

Currently I rewrote my templates and shortcodes with more HTML to accommodate this limitation.


{{% test/gallery class=“content-gallery” %}}
# Some markdown
and **some text**
{{< test/img src="/images/one.jpg" >}}
{{< test/img src="/images/two.jpg" >}}
{{% /test/gallery %}}

Does this solution require unsafe to be true for the Goldmark processor? Or is there a way to do this “safely”?