mirror of
git://git.proxmox.com/git/pve-docs.git
synced 2025-01-06 13:17:48 +03: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') ||
|
||||
(($env eq 'manvolnum') && ($man_target eq 'wiki'))) {
|
||||
|
||||
push @$cmd, '-s';
|
||||
|
||||
if (-f "./asciidoc/mediawiki.conf") {
|
||||
my $cwd = getcwd();
|
||||
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:[<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
|
||||
|
Loading…
Reference in New Issue
Block a user