////////////////////////////////////////////////////////////////////////// // asciidoc JS helper for Proxmox VE mediawiki pages // // code based on original asciidoc.js, but re-written using jQuery // ////////////////////////////////////////////////////////////////////////// var asciidoc = { // toc generator toc: function () { var tocholder = $("#toc"); if (!tocholder) { return; } tocholder.html(''); tocholder.hide(); var html = "

Contents

"; if (n > 3) { tocholder.html(html); tocholder.show(); } }, // footnote generator footnotes: function () { var noteholder = $("#footnotes"); if (!noteholder) { return; } noteholder.html(''); // Rebuild footnote entries. var refs = {}; var n = 0; var inner_html = ''; $("#asciidoccontent span.footnote").each(function(){ n++; var span = $(this); var note = span.attr("data-note"); var id = span.attr("id"); if (!note) { // Use [\s\S] in place of . so multi-line matches work. // Because JavaScript has no s (dotall) regex flag. note = span.html().match(/\s*\[([\s\S]*)]\s*/)[1]; span.html("[" + n + "]"); span.attr("data-note", note); } inner_html += "
" + "" + n + ". " + note + "
"; if (id != null) { refs["#"+id] = n; } }); if (inner_html) { noteholder.html("
" + inner_html); } if (n != 0) { // process footnoterefs. $("#asciidoccontent span.footnoteref").each(function(){ var span = $(this); var href = span.find("a").first().attr("href"); href = href.match(/#.*/)[0]; // in case it return full URL. n = refs[href]; span.html("[" + n + "]"); }); } } }; $(document).ready(function(){ asciidoc.footnotes(); asciidoc.toc(); });