-
-
Save guilhermechapiewski/379469 to your computer and use it in GitHub Desktop.
Create a "Table of Contents" in your Github wiki
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function () { | |
var toc = $("<ul>").css("margin-bottom", "20px !important"); | |
$("div.main div.wikistyle h2").each(function() { | |
var id = $(this).text().replace(/\s+/g, "_").replace(/[^0-9a-zA-Z_.-]/g, "") | |
$(this).attr("id", id) | |
toc.append( | |
$("<li>").append($("<b>").append($("<a>").attr("href", "#" + id).text($(this).text()))) | |
) | |
}); | |
$("div.wikistyle").prepend(toc).prepend($("<h2>").text("Table of Contents")); | |
}) |
According to http://support.github.com/discussions/repos/4299-auto-generate-table-of-contents-in-wiki-pages this can no longer work.
I developed GitHub Wikifier: A pre-commit Git Hook that will generate all the Table of Contents you will ever need. Just write your content, and let it take over. May be worth a check. https://github.com/kuroir/GitHub-Wikifier
You can get auto-generated TOC by using doc type AsciiDoc and inserting :toc:
.
it appears :toc:
doesn't work, as per https://github.com/artificialwisdomai/origin/wiki/Home/d0a63b257f2aeeec6aaa79304d53e190b1a439c3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do I use this? Or where do I put it to make it work?