From: Dietmar Maurer Date: Sat, 22 Oct 2016 08:57:06 +0000 (+0200) Subject: add code to generate correct footnotes on wiki pages X-Git-Url: https://git.proxmox.com/?p=pve-docs.git;a=commitdiff_plain;h=110ebe8fe1fc1bfc6b28428e1c310704313819d2 add code to generate correct footnotes on wiki pages --- diff --git a/asciidoc-pve.in b/asciidoc-pve.in index 92b0ca2..8550bac 100644 --- a/asciidoc-pve.in +++ b/asciidoc-pve.in @@ -388,8 +388,6 @@ sub compile_asciidoc { if (($env eq 'wiki') || (($env eq 'manvolnum') && ($man_target eq 'wiki'))) { - push @$cmd, '-s'; - if (-f "./asciidoc/mediawiki.conf") { my $cwd = getcwd(); push @$cmd, '-b', "$cwd/asciidoc/mediawiki"; diff --git a/asciidoc/asciidoc.js b/asciidoc/asciidoc.js new file mode 100644 index 0000000..5882248 --- /dev/null +++ b/asciidoc/asciidoc.js @@ -0,0 +1,65 @@ +////////////////////////////////////////////////////////////////////////// +// asciidoc JS helper for Proxmox VE mediawiki pages +// +// code based on original asciidoc.js, but re-written using jQuery +// +////////////////////////////////////////////////////////////////////////// + +var asciidoc = { + + // 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(); +}); + diff --git a/asciidoc/mediawiki.conf b/asciidoc/mediawiki.conf index 41366ea..5543429 100644 --- a/asciidoc/mediawiki.conf +++ b/asciidoc/mediawiki.conf @@ -133,7 +133,7 @@ template::[toc] [footnote-inlinemacro] # footnote:[]. -[{0}] +
[{0}]
[footnoteref-inlinemacro] # footnoteref:[], create reference to footnote. @@ -528,16 +528,20 @@ bodydata=| [toc] -
-
{toc-title}
- -
+ [header] - + + +template::[toc] +
[footer] +
+
[footer-date] # Default footer date is document modification time