]>
git.proxmox.com Git - pve-docs.git/blob - asciidoc/asciidoc.js
1 //////////////////////////////////////////////////////////////////////////
2 // asciidoc JS helper for Proxmox VE mediawiki pages
4 // code based on original asciidoc.js, but re-written using jQuery
6 //////////////////////////////////////////////////////////////////////////
12 var tocholder
= $("#toc");
20 var html
= "<div id=\"toctitle\"><h2>Contents</h2></div><ul>";
23 $("#asciidoccontent div.sect1").each(function(){
24 var h
= $(this).find("h2").first();
25 var id
= h
.attr("id");
28 html
+= "<li class=\"toclevel-1\">" +
29 "<a href=\"#" + id
+ "\">" +
30 "<span class=\"toctext\">" + h
.html() +
44 footnotes: function () {
45 var noteholder
= $("#footnotes");
52 // Rebuild footnote entries.
57 $("#asciidoccontent span.footnote").each(function(){
60 var note
= span
.attr("data-note");
61 var id
= span
.attr("id");
63 // Use [\s\S] in place of . so multi-line matches work.
64 // Because JavaScript has no s (dotall) regex flag.
65 note
= span
.html().match(/\s*\[([\s\S]*)]\s*/)[1];
66 span
.html("[<a id='_footnoteref_" + n
+ "' href='#_footnote_" +
67 n
+ "' title='View footnote' class='footnote'>" + n
+
69 span
.attr("data-note", note
);
72 "<div class='footnote' id='_footnote_" + n
+ "'>" +
73 "<a href='#_footnoteref_" + n
+ "' title='Return to text'>" +
74 n
+ "</a>. " + note
+ "</div>";
76 if (id
!= null) { refs
["#"+id
] = n
; }
79 if (inner_html
) { noteholder
.html("<hr>" + inner_html
); }
82 // process footnoterefs.
83 $("#asciidoccontent span.footnoteref").each(function(){
85 var href
= span
.find("a").first().attr("href");
86 href
= href
.match(/#.*/)[0]; // in case it return full URL.
88 span
.html("[<a href='#_footnote_" + n
+
89 "' title='View footnote' class='footnote'>" + n
+ "</a>]");
95 $(document
).ready(function(){