You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: markdown: Table of Contents (with_toc_data) #904
add a syntax directive for including a Table of Contents (TOC) in markdown documents
redcarpet now supports a with_toc_data (--render-with-toc-data) option for automatically generating a Table of Contents <ul> from markdown setext (=,_ underline) and ATX (# prefix) headings.
I strongly second this: every major markup language for wikis has a table-of-contents feature. The sheer number of people who have created scripts, userscripts and online tools in this thread to help us do it manually goes to show how important such a feature is! Not to mention the almost 300 comments there - mostly "+1" comments as one is quick to notice.
There are several questions on Stack Overflow about this as well, not to mention other sites:
Sure GitHub offers other markup languages that have this feature but markdown is their default one by choice - there is no excuse for them not to go ahead and deal with this issue once and for all.
Reacted by TPS, Morgan Bauer, Andrew Balmos, Anthony Trimble, Michael Maier, Brenden Kromhout, Antonio Stoilkov, Mark Polyak, Michael Hulse, Anton W and 14 more
Reacted by TPS, Samantha, Asbjørn Ulsberg, Stéphane Lavergne and Andrea Egan
Reacted by TPS, Samantha, Asbjørn Ulsberg, Larry West, Wabuo and Stéphane Lavergne
I've just received a reply from GH on this. Spoiler alert: its pretty depressing, despite this issue already having over 40 thumbs up when I wrote to them.
If a GH staff member is reading this please forgive me but doesn't look like they care at all since they couldn't be bothered to even make a comment here or in the linked thread. As you can see from the other thread that is pretty much their default reply every time they're contacted so I'm really having a hard time believing something will be done about this in the next few years.
Thanks GH, up to now I had nothing but respect for this website.
Thanks for reaching out! We don't comment publicly on our roadmap, so I'm not able to say if or when this will happen, but I will definitely add your +1 to the feature on our internal feature request list.
Thanks again for reaching out and for using GitHub!
Regards,
GitHub Support
Reacted by TPS, Stéphane Lavergne, Ashok Bakthavathsalam and Federico Diaz Real
EDIT: Now that I think of it there is zero evidence they even bothered to open up the link and see this issue. I've also cleaned up my last comment since it was badly written.
Reacted by tukkek, Wabuo, TPS, jbaron-gingco, José Luis Cruz, Chris Coggburn, sparanoid, lars van gemerden, Simon Elsbrock, Stéphane Lavergne and 1 more
Jekyll has support for a table of contents via Kramdown:
-
{:toc}
NOTE: There's a space after that hyphen that's required for it to work properly.
It's not particularly flexible, but given that GitHub Pages is running Jekyll, it could be worthwhile to use this style of ToC generation — that way if I'm looking at the source for a GH Pages site, the ToC works on the live site and the Jekyll-generated site without issues.
Personally, I'd favor consistency over flexibility in this case. The lower learning curve for new users and decreased complexity to implement/maintain/support is a plus, too.
Reacted by Raphael Dumas, Vitalii Chernookyi, Stéphane Lavergne, TPS and Kaustubh
I personally prefer to have a toggle content (toggle content under a title/header line) and/or table of contents switch on the top right corner of the Github markdown preview page. Currently, we have already had blame, history and source buttons on the top menu. Why not add another as/under a default preview options button defined by who created the doc and can be changed by readers?
The technical difficulty might be a burden on the server to generate previous pages case by case for different repos and/or for various readers. But I don't see why this cannot be done by GitHub staff.
@jlengstorf@westurner The problem of having an explicit {:toc} code line on the markdown doc is that the doc might be rendered using another markdown markup engine to generate a Github page or something else, and adding lines like {:toc} might bring in some conflicts or unexpected results on the resulted Github pages or other products.
I have also thought about enabling a global switch on one's github setting page, but the level of granular control of rendering seems too rough if one only wants to generate a table of contents or toggle all headers/titles on a few github pages. In the meantime, a reader can definitely have some level of control over what effect they want to see on markdown preview pages, but should the writer/owner of a doc have the control over the preview effect at the first place?
Just my 2cent. Of course, my 👍 to those who opens this issue and who contribute.
I personally prefer to have a toggle content (toggle content under a title/header line) and/or table of contents switch on the top right corner of the Github markdown preview page.
@i2000s I'm not sure I follow what you're suggesting, but it seems it might be an entirely separate feature request.
The problem of having an explicit {:toc} code line on the markdown doc is that the doc might be rendered using another markdown markup engine
This is fair, but GitHub has already thrown in with Jekyll (and, by proxy, Kramdown) for GitHub Pages. It's the default there. What I'm suggesting is adding cross-channel support so that the GitHub default and the GitHub Pages default versions of Markdown files are consistent.
Anyone using alternative Markdown syntax is already generating their GH Pages files before sending up to GitHub, so this wouldn't break anything, and the lack of support for non-standard Markdown wouldn't change. Unless I'm missing something, this would be a non-breaking change that most people wouldn't notice — people using Jekyll would see improvements in the Markdown rendering on github.com, and that's all.
We're now using CommonMark, so feature requests of this sort should go to CommonMark Discussion or our support team if we were going to consider adding it to our own cmark implementation. Thanks!
Reacted by Wes Turner, tukkek, Stéphane Lavergne, Ariel Balter, TPS, Brandon Curtis, std4453 and austin-plixer
Utilizing CommonMark doesn't necessarily mean GitHub can't provide a supplemental tool for this. I'm not sure closing this issue will help resolve it one way or the other.
In the meantime, I created a supplemental JavaScript-based solution for this: table-of-contents-generator. Hope it's helpful to others who find this thread.
@westurner@freelance-tech-writer This repository is the markup gem, and the issues are for issues relating to the gem specifically (e.g. it's incorrectly interacting with one of its dependency gems, or a change to pod2html, or a version bump for a dependency).
Seeing as this is a feature request for github.com's Markdown support, it should go to our support team so that it gets to the right avenues, is tracked and prioritised accordingly, etc. I've closed the issue because it just doesn't relate to the repository at all (and indeed, there is no repository for site feature requests; that's why we have a support team to collate them and respond to them).
@kivikakk So, you sent an email to support@github.com? Or one or more of these 159+ people need to send an email to support@github.com requesting a "Markdown Table of Contents" as discussed in #904 ?
@westurner It's better to use the form. We are aware of the feature request already (it's been made a few times), but if you want to add your voice, you're welcome to.
As you'd know if you'd actually read this issue's log, I have contacted GH support already concerning this and nothing came out of it. Telling people to try that avenue is inefficient at best and dubious at worst.
Reacted by Stéphane Lavergne, Wabuo, TPS, talpay, Eduard Dudar and std4453
Issue has almost 200 likes (or over 300 if you look at the post I linked to last year). GitHub's reaction: close it due to technicalities without as much as a follow-up ticket on the appropriate repository. Cool story @kivikakk, outstanding work!
I just sent a feature request for TOC via the form mentioned in that comment and got a quick response:
Hi Andreas,
Thanks for reaching out to GitHub Support!
I agree, a Table of Content would be great to have. We'll be sure to pass this feature request onto the team. I can't make any promises on this, but your request has definitely been noted!
Have a great day further!
Cheers,
John
GitHub Support
Obviously, this is no indication that Team GitHub will implement it, but here's to hoping 🍻.
I'm not deliberately trying to poison anything, I'm just amazed that a GH employee can close an issue with hundreds of upvotes without as much as opening a new one in the appropriate forum. If that's not subpar service I don't know what is.
Nice of you to contact customer support, like several others before you. You can see though there's no follow up or accountability there as well, they've just sent you the cookie cutter response they do to everyone who tries and your message goes to the trash folder as fast as it came.
Does GH have an obligation to follow up on any of that or actually provide us with more info? Not at all. Doesn't change the fact they're treating the hundreds of users who have liked, subscribed and participated on this an related issues with something akin to contempt. Really, how much time does it take for GH to officially follow up on this in the Common Mark tracker? Literally a couple of minutes, they just don't care.
Reacted by Stéphane Lavergne, TPS, Alexander Gabriel, Eduard Dudar and Chris Johnson
I totally agree. What's really rude is that the fact of transitioning to Common Mark as absolutely nothing to do with having a TOC feature. Fine, it's Common Mark now. But we still want a TOC, just in Common Mark.
Reacted by tukkek, Stéphane Lavergne, TPS, Kamil Kurzacz and Chris Johnson
But the "contents" directive can't do its work until the entire document has been parsed and possibly transformed to some extent. So the directive code leaves a placeholder behind that will trigger the second phase of its processing [...]
Activity
westurner commentedon Jun 19, 2016
Coming from ReStructuredText (docutils (setext)), auto-generated Table of Contents directives are a really useful feature.
tukkek commentedon Jul 8, 2016
I strongly second this: every major markup language for wikis has a table-of-contents feature. The sheer number of people who have created scripts, userscripts and online tools in this thread to help us do it manually goes to show how important such a feature is! Not to mention the almost 300 comments there - mostly "+1" comments as one is quick to notice.
There are several questions on Stack Overflow about this as well, not to mention other sites:
Sure GitHub offers other markup languages that have this feature but markdown is their default one by choice - there is no excuse for them not to go ahead and deal with this issue once and for all.
tukkek commentedon Jul 28, 2016
I've just received a reply from GH on this. Spoiler alert: its pretty depressing, despite this issue already having over 40 thumbs up when I wrote to them.
If a GH staff member is reading this please forgive me but doesn't look like they care at all since they couldn't be bothered to even make a comment here or in the linked thread. As you can see from the other thread that is pretty much their default reply every time they're contacted so I'm really having a hard time believing something will be done about this in the next few years.
Thanks GH, up to now I had nothing but respect for this website.
tukkek commentedon Jul 28, 2016
EDIT: Now that I think of it there is zero evidence they even bothered to open up the link and see this issue. I've also cleaned up my last comment since it was badly written.
abalter commentedon Sep 26, 2016
Make sure it's known that there are a zillion people here who want it.
isaacs/github#215
franslundberg commentedon Oct 12, 2016
+1. Please, implement this crucial feature.
brabenetz commentedon Oct 29, 2016
+1
joihelgi commentedon Nov 8, 2016
+1
steel commentedon Nov 9, 2016
+1
jlengstorf commentedon Dec 15, 2016
Jekyll has support for a table of contents via Kramdown:
NOTE: There's a space after that hyphen that's required for it to work properly.
It's not particularly flexible, but given that GitHub Pages is running Jekyll, it could be worthwhile to use this style of ToC generation — that way if I'm looking at the source for a GH Pages site, the ToC works on the live site and the Jekyll-generated site without issues.
Personally, I'd favor consistency over flexibility in this case. The lower learning curve for new users and decreased complexity to implement/maintain/support is a plus, too.
i2000s commentedon Dec 22, 2016
I personally prefer to have a
toggle content(toggle content under a title/header line) and/ortable of contentsswitch on the top right corner of the Github markdown preview page. Currently, we have already hadblame,historyandsourcebuttons on the top menu. Why not add another as/under adefault preview optionsbutton defined by who created the doc and can be changed by readers?The technical difficulty might be a burden on the server to generate previous pages case by case for different repos and/or for various readers. But I don't see why this cannot be done by GitHub staff.
@jlengstorf @westurner The problem of having an explicit
{:toc}code line on the markdown doc is that the doc might be rendered using another markdown markup engine to generate a Github page or something else, and adding lines like{:toc}might bring in some conflicts or unexpected results on the resulted Github pages or other products.I have also thought about enabling a global switch on one's github setting page, but the level of granular control of rendering seems too rough if one only wants to generate a table of contents or toggle all headers/titles on a few github pages. In the meantime, a reader can definitely have some level of control over what effect they want to see on markdown preview pages, but should the writer/owner of a doc have the control over the preview effect at the first place?
Just my 2cent. Of course, my 👍 to those who opens this issue and who contribute.
jlengstorf commentedon Dec 27, 2016
@i2000s I'm not sure I follow what you're suggesting, but it seems it might be an entirely separate feature request.
This is fair, but GitHub has already thrown in with Jekyll (and, by proxy, Kramdown) for GitHub Pages. It's the default there. What I'm suggesting is adding cross-channel support so that the GitHub default and the GitHub Pages default versions of Markdown files are consistent.
Anyone using alternative Markdown syntax is already generating their GH Pages files before sending up to GitHub, so this wouldn't break anything, and the lack of support for non-standard Markdown wouldn't change. Unless I'm missing something, this would be a non-breaking change that most people wouldn't notice — people using Jekyll would see improvements in the Markdown rendering on github.com, and that's all.
kivikakk commentedon Mar 23, 2017
We're now using CommonMark, so feature requests of this sort should go to CommonMark Discussion or our support team if we were going to consider adding it to our own
cmarkimplementation. Thanks!westurner commentedon Mar 23, 2017
@kivikakk I wouldn't close this because the feature is not implemented? wontfix? pending CommanMark standardization?
Information that would be helpful in satisfying the clear demand for this feature (158 👍, 9 ❤️):
And then a post here when it's implemented would be really cool.
freelance-tech-writer commentedon Mar 28, 2017
Utilizing CommonMark doesn't necessarily mean GitHub can't provide a supplemental tool for this. I'm not sure closing this issue will help resolve it one way or the other.
In the meantime, I created a supplemental JavaScript-based solution for this: table-of-contents-generator. Hope it's helpful to others who find this thread.
kivikakk commentedon Mar 28, 2017
@westurner @freelance-tech-writer This repository is the
markupgem, and the issues are for issues relating to the gem specifically (e.g. it's incorrectly interacting with one of its dependency gems, or a change topod2html, or a version bump for a dependency).Seeing as this is a feature request for github.com's Markdown support, it should go to our support team so that it gets to the right avenues, is tracked and prioritised accordingly, etc. I've closed the issue because it just doesn't relate to the repository at all (and indeed, there is no repository for site feature requests; that's why we have a support team to collate them and respond to them).
westurner commentedon Mar 28, 2017
@kivikakk So, you sent an email to support@github.com? Or one or more of these 159+ people need to send an email to support@github.com requesting a "Markdown Table of Contents" as discussed in #904 ?
kivikakk commentedon Mar 28, 2017
@westurner It's better to use the form. We are aware of the feature request already (it's been made a few times), but if you want to add your voice, you're welcome to.
tukkek commentedon Mar 28, 2017
As you'd know if you'd actually read this issue's log, I have contacted GH support already concerning this and nothing came out of it. Telling people to try that avenue is inefficient at best and dubious at worst.
tukkek commentedon Mar 28, 2017
Issue has almost 200 likes (or over 300 if you look at the post I linked to last year). GitHub's reaction: close it due to technicalities without as much as a follow-up ticket on the appropriate repository. Cool story @kivikakk, outstanding work!
AndreasHassing commentedon Mar 29, 2017
@tukkek please stop poisoning this issue, it's closed and you have been given a way to formally request this feature.
I just sent a feature request for TOC via the form mentioned in that comment and got a quick response:
Obviously, this is no indication that Team GitHub will implement it, but here's to hoping 🍻.
tukkek commentedon Mar 29, 2017
I'm not deliberately trying to poison anything, I'm just amazed that a GH employee can close an issue with hundreds of upvotes without as much as opening a new one in the appropriate forum. If that's not subpar service I don't know what is.
Nice of you to contact customer support, like several others before you. You can see though there's no follow up or accountability there as well, they've just sent you the cookie cutter response they do to everyone who tries and your message goes to the trash folder as fast as it came.
Does GH have an obligation to follow up on any of that or actually provide us with more info? Not at all. Doesn't change the fact they're treating the hundreds of users who have liked, subscribed and participated on this an related issues with something akin to contempt. Really, how much time does it take for GH to officially follow up on this in the Common Mark tracker? Literally a couple of minutes, they just don't care.
abalter commentedon Mar 29, 2017
I totally agree. What's really rude is that the fact of transitioning to Common Mark as absolutely nothing to do with having a TOC feature. Fine, it's Common Mark now. But we still want a TOC, just in Common Mark.
abalter commentedon Mar 29, 2017
#1036
westurner commentedon Mar 29, 2017
TOC Implementations
(id=slugify(name), name=name)# ## ### ####(#prefix (level n))=====,-----(underline (level 1, 2))id=for each h1, h2, h3, h4 (So that #deep-links-work)Thing 123 and 1234->thing-andORthing-123-and-1234id=for each TOC a tag (So that headings can link back to the TOC):local:(docutils (public domain))test case
Contents
- h4-1-0-0-0
jgm/CommonMark
Python-Markdown
jonschlinkert/markdown-toc
jgm/cmark
github/cmark
commonmark spec
Table of Contents syntax
toc-implementations-288622154(slug-futurecommentid)docutils
class pendingclass Contents(docutils.parsers.rst.directive.parts:Contents)class Contents(docutils.transforms.parts:Contents)abalter commentedon Mar 29, 2017
#1037
westurner commentedon Jan 31, 2019
CommonMark:
"Feature request: automatically generated ids for headers" https://talk.commonmark.org/t/feature-request-automatically-generated-ids-for-headers/115
"HTML table-of-contents renderer"
HTML table-of-contents renderer commonmark/cmark#78
westurner commentedon Jan 31, 2019
Build-less tables of contents are possible with .mediawiki (by default) and .rst/.rest documents (with a
.. contents::directive); since launch.(I've emailed a feature request for TOC on Markdown documents)
Are there other great tools for handling this need with e.g. an entry in a Makefile and an offline build step?