Last active — forked from tekkub/github_wiki_toc.js

Create a "Table of Contents" in your Github wiki

  • Download Gist
1 2 3 4 5 6 7 8 9 10 11
$(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)
$("<li>").append($("<b>").append($("<a>").attr("href", "#" + id).text($(this).text())))
$("div.wikistyle").prepend(toc).prepend($("<h2>").text("Table of Contents"));

How do I use this? Or where do I put it to make it 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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.