Nested shortcodes break markdown formatting [Solved]


#1

Hey guys after some searching and reading the docs and other posts responses I’m writing this so apologies beforehand if I didn’t quite understand how shortcodes are supposed to work.

I’m trying to make a shortcode that formats my content a specific way ie:

<div id="{{.Get "name}}">
    <h3>{{.Get "name"}}</h3>
    {{.Inner}}
</div>

So when I use this shortcode in my markdown I write it something like this:

{{< section name="Cool Title" >}}
    Some **markdown** content here
    {{< image name="image/path.jpg" >}}
{{ < /section >}}

When I do this my markdown formatting breaks :frowning: I tried changing my markdown syntax to use % instead of < > but it breaks the nested shortcodes, can anyone provide any feedback as to how I can achieve this or is this not possible?

Thanks.


#2

Try doing {{ .Inner | safeHTML }} in the outer shortcodes to include the HTML of the inner ones.

Actually, I should try that. My theme documentation just says “only use {{<>}}”…


#3

Thanks but that wasn’t the problem, the problem was I had an error in my image shortcode which was nested causing everything to break I feel so stupid, live and learn.