-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
ENH: markdown: Table of Contents (with_toc_data) #904
Comments
Coming from ReStructuredText (docutils (setext)), auto-generated Table of Contents directives are a really useful feature. .. ```restructuredtext
.. contents::
.. contents:: Table of Contents 2
:depth: 10
:local: |
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. |
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.
|
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. |
Make sure it's known that there are a zillion people here who want it. |
+1. Please, implement this crucial feature. |
+1 |
2 similar comments
+1 |
+1 |
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. |
I personally prefer to have a 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 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. |
@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. |
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 |
@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. |
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 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. |
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! |
@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 🍻. |
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. |
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. |
TOC Implementations
test case#### Contents
- [h1-0](#h1-0)
- [h2-0-0](#h2-0-0)
- [h3-0-0-0](#h3-0-0-0)
- [Thing 123 and 1234](#thing-123-and-1234)
- [h1-1](#h1-1)
- [h4-1-0-0-0](#h4-1-0-0-0) Contentsjgm/CommonMark
Python-Markdown
jonschlinkert/markdown-toc
jgm/cmarkgithub/cmarkcommonmark spec
Table of Contents syntax
docutilsdocutils ``contents`` directive
================================
.. contents:: Contentz
:depth: 3
:local:
|
CommonMark:
|
Build-less tables of contents are possible with .mediawiki (by default) and .rst/.rest documents (with a (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? |
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.with_toc_data
: GitHub style anchors ", Changelog entry)&
not rendering correctly)The text was updated successfully, but these errors were encountered: