Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to control/increase the Heading levels suppported by TOC Plugin #1023

Closed
dvdmtw98 opened this issue May 7, 2023 · 8 comments
Closed
Labels
enhancement New feature or request inactive No activity

Comments

@dvdmtw98
Copy link

dvdmtw98 commented May 7, 2023

NOTE: Before you start, the following should be completed.

  • Read Wiki to understand the usage and the correct effect of functional design.
  • Make sure no similar issue(including closed ones) exists.
  • Make sure the request is based on the latest code in the master branch.

Is your feature request related to a problem? Please describe

The new TOC plugin (tocbot) that has been introduced in Chirpy only works for H2 and H3. In all my articles I only use heading levels H3 and below become of which Chirpy does not show H4, H5 headers as part of the Table of Content.

Describe the solution you'd like

If the TOC plugin has been limited to H2 and H3 because of performance reasons it would be great if an option in the config file was introduced where we can mention which levels of Headers should be considered for generating the TOC.

Describe alternatives you've considered

Additional context

Other Issues related to TOC plugin: #1013

@dvdmtw98 dvdmtw98 added the enhancement New feature or request label May 7, 2023
@v4vong
Copy link
Contributor

v4vong commented May 7, 2023

Vote +1

@cotes2020
Copy link
Owner

The reason why the TOC only displays h2 ~ h3 headings is not due to performance, but rather to consider the horizontal width of multi-level headings.

If three levels (h2 ~ h4) are displayed, the text of the third level (h4) heading will wrap multiple times. I think this is also the reason why mainstream web design only displays h2 to h3.

@v4vong
Copy link
Contributor

v4vong commented May 13, 2023

The reason why the TOC only displays h2 ~ h3 headings is not due to performance, but rather to consider the horizontal width of multi-level headings.

If three levels (h2 ~ h4) are displayed, the text of the third level (h4) heading will wrap multiple times. I think this is also the reason why mainstream web design only displays h2 to h3.

But I think many guys would want to show h4 in TOC if they want to write a very long blog post with a complex structure. So the best solution may be to make it optional.

@dvdmtw98
Copy link
Author

The reason why the TOC only displays h2 ~ h3 headings is not due to performance, but rather to consider the horizontal width of multi-level headings.

If three levels (h2 ~ h4) are displayed, the text of the third level (h4) heading will wrap multiple times. I think this is also the reason why mainstream web design only displays h2 to h3.

I also still feel like at least the option to show h4 should be added so who needs it can enable it.
I remember seeing the h4 headers showing up in the previous TOC plugin that was used in Chirpy. Did not notice any width related issues either.

@NichtsHsu
Copy link
Contributor

If three levels (h2 ~ h4) are displayed, the text of the third level (h4) heading will wrap multiple times.

If this is the problem, I think text-overflow: ellipsis can be a solution.

@JoaoF17
Copy link

JoaoF17 commented Jun 9, 2023

In my case TOC is not displaying on my posts even for h2 and h3 even though I have TOC set to true in _config.yml. Has anyone had this issue before?

@otzslayer
Copy link

I've been modifying it myself so that H4 appears in the ToC, but I'm not sure if there's a problem.

otzslayer@2128083

This is the commit I pushed to use, and it looks fine on my blog at the moment.

https://otzslayer.github.io/cs224w/2023/06/16/cs224w-05.html#%EC%A0%84%ED%86%B5%EC%A0%81%EC%9D%B8-gnn-%EB%A0%88%EC%9D%B4%EC%96%B4-1-gcn

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the inactive No activity label Jul 19, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
gudtldn pushed a commit to gudtldn/gudtldn.github.io that referenced this issue Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request inactive No activity
Projects
None yet
Development

No branches or pull requests

6 participants