Quantcast
Channel: Sections wrapped in a shortcode do not appear in the TOC
Viewing all articles
Browse latest Browse all 15

Sections wrapped in a shortcode do not appear in the TOC

$
0
0

@pointyfar wrote:

Given the following content:

## Lorem 
1. one
2. *two*

{{< test >}}

## h2 inside &lt; shortcode
1. three
2. *four*

### h3 inside &lt; shortcode 
1. five
2. *six*

{{< /test >}}

---

## Sit
1. one
2. *two*

{{% test %}}
## h2 inside % shortcode
1. three
2. *four*

### h3 inside % shortcode
1. five
2. *six*
{{% /test %}}

The following shortcode test.html:

Inside: 
{{.Inner }}
End 

The following layout:

{{.TableOfContents}}
{{.Content}}

I get the following output:

<div>
  <nav id="TableOfContents">
    <ul>
      <li>
        <ul>
          <li><a href="#lorem">Lorem</a></li>
          <li><a href="#sit">Sit</a></li>
          <li><a href="#h2-inside-shortcode">h2 inside % shortcode</a>
            <ul>
              <li><a href="#h3-inside-shortcode">h3 inside % shortcode</a></li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </nav>

  <h2 id="lorem">Lorem</h2>
  <ol>
    <li>one</li>
    <li><em>two</em></li>
  </ol>

  Inside:
  ## h2 inside &lt; shortcode
  1. three
  2. *four*
  ### h3 inside &lt; shortcode
  1. five
  2. *six*
  End

  <hr>

  <h2 id="sit">Sit</h2>
  <ol>
    <li>one</li>
    <li><em>two</em></li>
  </ol>

  <p>Inside:</p>
  <h2 id="h2-inside-shortcode">h2 inside % shortcode</h2>
  <ol>
    <li>three</li>
    <li><em>four</em></li>
  </ol>

  <h3 id="h3-inside-shortcode">h3 inside % shortcode</h3>
  <ol>
    <li>five</li>
    <li><em>six</em></li>
  </ol>

  <p>End</p>
</div>

In short: it works. I get Table of Contents, including the headings inside the shortcode. The markdown is also properly rendered inside the shortcode.

As per the docs, using {{% shortcode %}}, and not using markdownify inside the shortcode definition.

Do you get different results? Or is this not what you are tying to do?

Read full topic


Viewing all articles
Browse latest Browse all 15

Trending Articles