Skip to content

table of contents tag only displays 3 levels of headline #368

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

Closed
mxmilkiib opened this issue Feb 22, 2017 · 7 comments
Closed

table of contents tag only displays 3 levels of headline #368

mxmilkiib opened this issue Feb 22, 2017 · 7 comments
Labels
enhancement Wants to improvide an existing feature feature Wants to add a new feature Hacktoberfest

Comments

@mxmilkiib
Copy link

While I can see benefits for this in some situations, I have the first H1 as the document title so my 'third level' document body is ####, it would be handy if headers of level 4 (and possibly 5) could be displayed via [TOC] or maybe a new tag.

@a60814billy
Copy link
Member

Thanks @milkmiruku
Maybe we can add option to TOC tag,
like [TOC level=4] to set TOC level ?

@a60814billy a60814billy added enhancement Wants to improvide an existing feature feature Wants to add a new feature minor and removed minor labels Feb 23, 2017
@ccoenen
Copy link
Contributor

ccoenen commented Feb 23, 2017

@milkmiruku if you only need the title for list/overview, you could also add it to the yaml metadata at the top like this

---
title: This is my awesome document. There are many like it, but this one is mine!
---

see https://hackmd.io/yaml-metadata for more detailed info.

@mxmilkiib
Copy link
Author

@ccoenen thanks, it's more I'd like to use h1 for the document name/title. An alternative idea could be an option to shunt the TOC so it ignores h1 (if there is only one)?

@jackycute
Copy link
Member

@milkmiruku currently, we don't have an option for customizing TOC ranges.
But maybe this would be nice to have.

@jackycute
Copy link
Member

I found a good example for the YAML metadata options.

https://shd101wyy.github.io/markdown-preview-enhanced/#/toc?id=toc-and-sidebar-toc-configuration

@salim-b
Copy link

salim-b commented Jul 20, 2020

I found a good example for the YAML metadata options.

https://shd101wyy.github.io/markdown-preview-enhanced/#/toc?id=toc-and-sidebar-toc-configuration

An option to set the ToC depth would be really helpful!

Maybe you'd like to just use the same syntax as R Markdown does? It looks like this:

---
title: "Habits"
output:
  html_document:
    toc: true
    toc_depth: 2
---

Then we could set the ToC separately for each export format. Of course that would imply some additional implementation work, but since both HackMD/CodiMD and R Markdown/Knitr are relying on Pandoc to convert the Markdown, that would really make sense I guess (the above YAML keys correspond to Pandoc's CLI options --toc and --toc-depth). 🙃

@jackycute
Copy link
Member

jackycute commented May 12, 2021

We supported to change this by #1532
You can use YAML metadata or use [ToC maxLevel=4] to specify toc levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Wants to improvide an existing feature feature Wants to add a new feature Hacktoberfest
Projects
None yet
Development

No branches or pull requests

6 participants