mirror of
https://git.proxmox.com/git/pve-docs
synced 2025-05-30 19:24:57 +00:00
add code to generate correct footnotes on wiki pages
This commit is contained in:
parent
4aa7516da7
commit
110ebe8fe1
@ -388,8 +388,6 @@ sub compile_asciidoc {
|
|||||||
if (($env eq 'wiki') ||
|
if (($env eq 'wiki') ||
|
||||||
(($env eq 'manvolnum') && ($man_target eq 'wiki'))) {
|
(($env eq 'manvolnum') && ($man_target eq 'wiki'))) {
|
||||||
|
|
||||||
push @$cmd, '-s';
|
|
||||||
|
|
||||||
if (-f "./asciidoc/mediawiki.conf") {
|
if (-f "./asciidoc/mediawiki.conf") {
|
||||||
my $cwd = getcwd();
|
my $cwd = getcwd();
|
||||||
push @$cmd, '-b', "$cwd/asciidoc/mediawiki";
|
push @$cmd, '-b', "$cwd/asciidoc/mediawiki";
|
||||||
|
65
asciidoc/asciidoc.js
Normal file
65
asciidoc/asciidoc.js
Normal file
@ -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();
|
||||||
|
});
|
||||||
|
|
@ -133,7 +133,7 @@ template::[toc]
|
|||||||
|
|
||||||
[footnote-inlinemacro]
|
[footnote-inlinemacro]
|
||||||
# footnote:[<text>].
|
# footnote:[<text>].
|
||||||
<span class="footnote">[{0}]</span>
|
<span class="footnote"><br>[{0}]<br></span>
|
||||||
|
|
||||||
[footnoteref-inlinemacro]
|
[footnoteref-inlinemacro]
|
||||||
# footnoteref:[<id>], create reference to footnote.
|
# footnoteref:[<id>], create reference to footnote.
|
||||||
@ -528,16 +528,20 @@ bodydata=<td class="tableblock halign-{colalign=left}">|</td>
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
[toc]
|
[toc]
|
||||||
<div id="toc">
|
<!-- FIXME: 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>
|
|
||||||
|
|
||||||
[header]
|
[header]
|
||||||
<!-- HEADER -->
|
<!-- asciidoc HEADER -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
include1::asciidoc.js[]
|
||||||
|
</script>
|
||||||
|
template::[toc]
|
||||||
|
<div id="asciidoccontent">
|
||||||
|
|
||||||
[footer]
|
[footer]
|
||||||
<!-- FOOTER -->
|
<!-- FOOTER -->
|
||||||
|
</div>
|
||||||
|
<div id="footnotes"></div>
|
||||||
|
|
||||||
[footer-date]
|
[footer-date]
|
||||||
# Default footer date is document modification time
|
# Default footer date is document modification time
|
||||||
|
Loading…
Reference in New Issue
Block a user