Sign in

Variable depth in table of content generator

  • This topic has 4 replies, 2 voices, and was last updated 10 months, 2 weeks ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5047
    mlryan

    It would be useful to be able to specify the depth (h2,h3) of headings that are included in a generated table of contents. Currently it appears to generate as much depth as you have in your content. This is not always the desired outcome.

    The TOC also appears broken in a couple of ways:

    • It generates numbered links. If your H2/H3 text already includes a number, then it appears twice.
    • It does not handle a missing level very elegantly, in my case it included extra, blank entries in the TOC due to a missing level (My text was going straight from H2 to H4 in some cases by design)

    Example of this is at:

    https://www.fullonecommerce.com/ecommerce-platform-shortlist.html

     

    #5048
    Bob

    It generates numbered links. If your H2/H3 text already includes a number, then it appears twice.

    The table of contents generates links with text retrieved from the headings, so if the headings contain numbers, they will also appear in the TOC links – this is normal behavior.

    It does not handle a missing level very elegantly, in my case it included extra, blank entries in the TOC due to a missing level (My text was going straight from H2 to H4 in some cases by design)

    The outline level of the headings is incorrect, and the TOC based on that, displays empty items because it lacks the correct outline. Instead of using H4, use H3 heading with .h4 class:

    <h2>1. Dominant ecommerce platforms</h2>
    <h3 class="h4">Salesforce B2C Commerce</h3>

     

     

     

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #5049
    mlryan

    The table of contents generates links with text retrieved from the headings, so if the headings contain numbers, they will also appear in the TOC links – this is normal behavior.

    But then you get the numbers appearing twice, for example:

    1. “1. Topic One”

    which does not seem right. I guess this is down to the use of li::marker in the CSS which includes a font-variant-numeric

    marker {
    font-variant-numeric: tabular-nums;
    }

     

    I will have to adjust the CSS I guess.

    #5050
    Bob

    The default style of the TOC list comes with the numeric list-style-type, so this is why you see the numbers twice.

    You can change it via CSS; the list of all CSS classes generated by TOC can be found here: https://getpublii.com/dev/default-publii-classes-for-using-with-css/#table-of-contents-toc

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #5063
    mlryan

    Thanks for the responses, as always very helpful and I have implemented the change to using h3 class=”h4″. Unfortunately I can’t seem to get rid of the empty link (called 5.3) in the TOC structure on my page. Can you please have a quick look to see if I have missed something? Thanks in advance.

    https://www.fullonecommerce.com/ecommerce-platform-shortlist.html

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.