mirror of
https://git.proxmox.com/git/pve-docs
synced 2025-05-01 07:48:41 +00:00
add simple toc generator for wiki pages
This commit is contained in:
parent
110ebe8fe1
commit
7cbfd9192e
@ -7,6 +7,39 @@
|
|||||||
|
|
||||||
var asciidoc = {
|
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
|
// footnote generator
|
||||||
footnotes: function () {
|
footnotes: function () {
|
||||||
var noteholder = $("#footnotes");
|
var noteholder = $("#footnotes");
|
||||||
@ -61,5 +94,6 @@ var asciidoc = {
|
|||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
asciidoc.footnotes();
|
asciidoc.footnotes();
|
||||||
|
asciidoc.toc();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -528,7 +528,8 @@ bodydata=<td class="tableblock halign-{colalign=left}">|</td>
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
[toc]
|
[toc]
|
||||||
<!-- FIXME: TOC -->
|
<div id="toc" class="toc">
|
||||||
|
</div>
|
||||||
|
|
||||||
[header]
|
[header]
|
||||||
<!-- asciidoc HEADER -->
|
<!-- asciidoc HEADER -->
|
||||||
|
Loading…
Reference in New Issue
Block a user