5
0
mirror of git://git.proxmox.com/git/pve-docs.git synced 2025-03-20 22:50:06 +03:00

add simple toc generator for wiki pages

This commit is contained in:
Dietmar Maurer 2016-10-22 12:02:36 +02:00
parent 110ebe8fe1
commit 7cbfd9192e
2 changed files with 36 additions and 1 deletions

View File

@ -7,6 +7,39 @@
var asciidoc = {
// toc generator
toc: function () {
var tocholder = $("#toc");
if (!tocholder) {
return;
}
tocholder.html('');
tocholder.hide();
var html = "<div id=\"toctitle\"><h2>Contents</h2></div><ul>";
var n = 0;
$("#asciidoccontent div.sect1").each(function(){
var h = $(this).find("h2").first();
var id = h.attr("id");
if (id != null) {
n++;
html += "<li class=\"toclevel-1\">" +
"<a href=\"#" + id + "\">" +
"<span class=\"toctext\">" + h.html() +
"</span></a></li>";
}
});
html += "</ul>";
if (n > 3) {
tocholder.html(html);
tocholder.show();
}
},
// footnote generator
footnotes: function () {
var noteholder = $("#footnotes");
@ -61,5 +94,6 @@ var asciidoc = {
$(document).ready(function(){
asciidoc.footnotes();
asciidoc.toc();
});

View File

@ -528,7 +528,8 @@ bodydata=<td class="tableblock halign-{colalign=left}">|</td>
</div>
[toc]
<!-- FIXME: TOC -->
<div id="toc" class="toc">
</div>
[header]
<!-- asciidoc HEADER -->