]> git.proxmox.com Git - pve-docs.git/commitdiff
add code to generate correct footnotes on wiki pages
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 22 Oct 2016 08:57:06 +0000 (10:57 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 22 Oct 2016 08:57:06 +0000 (10:57 +0200)
asciidoc-pve.in
asciidoc/asciidoc.js [new file with mode: 0644]
asciidoc/mediawiki.conf

index 92b0ca2f4192ea43a7b28c87d4c8d61916449f43..8550bac19327bc52ef06c39f282ec7d9ac5534d9 100644 (file)
@@ -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 (file)
index 0000000..5882248
--- /dev/null
@@ -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("[<a id='_footnoteref_" + n + "' href='#_footnote_" +
+                         n + "' title='View footnote' class='footnote'>" + n +
+                         "</a>]");
+               span.attr("data-note", note);
+           }
+           inner_html +=
+            "<div class='footnote' id='_footnote_" + n + "'>" +
+               "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
+               n + "</a>. " + note + "</div>";
+           
+           if (id != null) { refs["#"+id] = n; }
+       });
+
+       if (inner_html) { noteholder.html("<hr>" + 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("[<a href='#_footnote_" + n +
+                         "' title='View footnote' class='footnote'>" + n + "</a>]");
+           });
+       }
+    }
+};
+
+$(document).ready(function(){
+    asciidoc.footnotes();
+});
+
index 41366eac63d462e1673ab135f14f9ef58656c311..554342945b2e435ea32a8cec0e62a62df26ad467 100644 (file)
@@ -133,7 +133,7 @@ template::[toc]
 
 [footnote-inlinemacro]
 # footnote:[<text>].
-<span class="footnote">[{0}]</span>
+<span class="footnote"><br>[{0}]<br></span>
 
 [footnoteref-inlinemacro]
 # footnoteref:[<id>], create reference to footnote.
@@ -528,16 +528,20 @@ bodydata=<td class="tableblock halign-{colalign=left}">|</td>
 </div>
 
 [toc]
-<div id="toc">
-  <div id="toctitle">{toc-title}</div>
-  <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
-</div>
+<!-- FIXME: TOC -->
 
 [header]
-<!-- HEADER -->
+<!-- asciidoc HEADER -->
+<script type="text/javascript">
+include1::asciidoc.js[]
+</script>
+template::[toc]
+<div id="asciidoccontent">
 
 [footer]
 <!-- FOOTER -->
+</div>
+<div id="footnotes"></div>
 
 [footer-date]
 # Default footer date is document modification time