# Markdownify function with nested shortcodes

**URL:** <https://discourse.gohugo.io/t/markdownify-function-with-nested-shortcodes/23689>\
**Category:** support\
**Created:** [February 26, 2020, 10:49pm UTC](https://discourse.gohugo.io/t/markdownify-function-with-nested-shortcodes/23689 "2020-02-26T22:49:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hayexo](https://avatars.discourse-cdn.com/v4/letter/h/b5e925/32.png) [@hayexo](https://discourse.gohugo.io/u/hayexo)\
**Post date:** [February 26, 2020, 10:49pm UTC](https://discourse.gohugo.io/t/markdownify-function-with-nested-shortcodes/23689/1 "2020-02-26T22:49:25Z")

</div>

I have an issue that is either due to my poor understanding of nested shortcodes, or my poor understanding of markdown (or probably both.)

This is an internal site so I don’t have a repository but I’ve recreated a basic representation below. Essentially this is an attempt to style some text and a couple images in a drop shadow.

I’m using the shortcode’s “Inner” feature as I would like to include text with multuiple lines. I have done that with other shortcodes with no issue in the past but this time it is complicated by having a nested image shortcode in that same text block.

So, my **box\_shadow\_text.html** shortcode:

```auto
<div class="myclass">
  <h3>{{ .Get "header_text" }}</h3>
  <p>{{ .Inner | markdownify }}</p>
</div>

```

My **simple\_img.html** shortcode

```auto
{{ with .Parent }}
    {{ $src := .Page.Resources.GetMatch (printf "%s" ($.Get "src")) }}
    {{ with $src }}
        <img src="{{ .RelPermalink }}">
    {{ end }}
{{ else }}
    {{ $src := .Page.Resources.GetMatch (printf "%s" ($.Get "src")) }}
    {{ with $src }}
        <img src="{{ .RelPermalink }}">
    {{ end }}
{{end}}

```

… and the **index.md** page

```auto
---
title: "MyTitle"
---

{{< box_shadow_text header_text="Header" >}}This is some text..
.. that I would like to display..

.. with multiple paragraphs.

{{< simple_img src="image_folder/image1jpg" >}}
{{< simple_img src="image_folder/image2jpg" >}}

{{</ box_shadow_text >}}

```

My problem is that when I use the _markdownify_ function on the .Inner text in my **box\_shadow\_text.html** shortcode the text appears correctly but the images appear as inline HTML code which kind of makes sense. If I remove the _markdownify_ I get the images as expected but the text is just one massive block without paragraph tags, which also kind of makes sense. I want the img tags from the **simple\_img.html** shortcode to be exempt from the markdownify function.

I found [this](https://discourse.gohugo.io/t/nested-shortcodes-break-markdown-formatting-solved/8105) forum post which initially looks like the same problem I’m having but using _safeHTML_ on the .Inner block results in the same output as removing _markdownify_ - the images show up but the text has no paragraph tags.

---

<div class="post-metadata">

**Author:** ![hayexo](https://avatars.discourse-cdn.com/v4/letter/h/b5e925/32.png) [@hayexo](https://discourse.gohugo.io/u/hayexo)\
**Post date:** [February 28, 2020, 2:17pm UTC](https://discourse.gohugo.io/t/markdownify-function-with-nested-shortcodes/23689/2 "2020-02-28T14:17:25Z")

</div>

I’ve tried all manner of fixes but still can’t make this work. So, for now I’ve resorted to splitting the shortcode into two individual files:

So, now I have a **box\_shadow\_text\_begin.html** shortcode:

```auto
<div class="myclass">
  <h3>{{ .Get "header_text" }}</h3>
  <p>

```

and a **box\_shadow\_text\_end.html** shortcode:

```auto
</p>
</div>

```

It’s ugly and I hate it but it’s the only way it works. I should probably lower my expectations and rethink things to avoid nesting shortcodes in the first place.
