Skip to content

[BUG] Unable to render TOC in org-mode files #1121

Open
@pace577

Description

@pace577

Describe the bug
When I try to generate the table of contents for a post with the ShowToc: true option, I don't see the TOC on the post as expected.

  • Device/Os: Manjaro
  • Type: Desktop
  • Browser and version: Mozilla Firefox 108.0.1
  • Hugo Version [ >=0.83.0 expected]: 0.108.0
  • Theme Version [e.g. v4.0, master, or commit-id ]: d3d90be

Steps to reproduce the behavior:

  1. Create an org file with hugo new post.org with at least one heading (Eg: * Heading )
  2. Add ShowToc: true in the front matter of post.
  3. Serve the site with hugo serve -D.
  4. Open the page and see that the TOC is not visible.

However, note that the TOC is displayed if a .md file was made instead of a .org file.

Expected behavior:
Table of Contents was supposed to appear as expected.

Additional context
Upon debugging, I found that changing the regexp in this line from <h[1-6].*?>(.|\n])+?</h[1-6]> to <h[1-6].*?>(.|\n)+?</h[1-6]> (removed a ] character in the middle) seems to give expected behaviour.

Making this change locally fixed the bug for me, but I do not understand why it happened!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions