Maintain tabs in shortcode without processing as code block?

example.md

{{% shortcode %}}Test{{% /shortcode %}}

shortcode.html

<div>
  <div>
    <div>
    {{ .Inner }}
    </div>
  </div>
</div>

Result

<div>
  <div>
    <div>
<p>Test</p>
<pre><code>&lt;/div&gt;
</code></pre>
  </div>
</div>

  </div>

Just curious if there is a way to maintain tabs for clarity while rendering as expected.

Often asked. Basically: No. You could do some magic by adding parameters, but then you need to know how far “in” you are already.

Also: Why do you need the indentation? In an optimum case you remove all white-spaces in production to get your page size down.

1 Like

I’d be fine with an output of:

<div><div><div>Test</div></div></div>

But it would be nice to still see the hierarchy when on the development side.

EDIT: For posterity, it seems that you can maintain most of the hierarchy as long as a tag isn’t left by itself. For example:

<div>
  <div>
  <div>
  {{ .Inner }}
  </div>
  </div>
</div>

or

<div>
  <div>
    <div>
    {{ .Inner }}
    </div>
  <span>{{ .Inner }}</span>
  </div>
</div>

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