@codedoc/core
Version:
Create beautiful modern documentation websites.
48 lines • 2.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.gatherFootnotes$ = exports.gatherFootnotes = void 0;
var transport_1 = require("@connectv/sdh/transport");
var renderer_1 = require("../../transport/renderer");
function gatherFootnotes() {
var renderer = renderer_1.getRenderer();
transport_1.onReady(function () {
var _exec = function () {
var counter = 1;
var collected = [];
var countermap = {};
document.querySelectorAll('[data-footnote], [data-footnotes]').forEach(function (child) {
if (child.hasAttribute('data-footnote')) {
var id = "--codedoc-footnote-" + (child.getAttribute('data-footnote-id') || counter);
var index = (id in countermap) ? countermap[id] : (countermap[id] = counter++);
if (child.childNodes.length > 0) {
child.setAttribute('id', id);
child.setAttribute('data-footnote-index', "" + index);
collected.push({ index: index, $: child });
}
if (!child.hasAttribute('data-footnote-block')) {
renderer.render(renderer.create("sup", null,
renderer.create("a", { href: "#" + id, style: "text-decoration: none" },
renderer.create("b", null, index)))).before(child);
}
child.remove();
}
else {
collected.sort(function (a, b) { return a.index - b.index; }).forEach(function (_) {
renderer.render(renderer.create("div", null,
renderer.create("span", null,
renderer.create("a", null,
renderer.create("b", null, _.index))),
" ",
_.$)).on(child);
});
collected = [];
}
});
};
_exec();
window.addEventListener('navigation', _exec);
});
}
exports.gatherFootnotes = gatherFootnotes;
exports.gatherFootnotes$ = transport_1.funcTransport(gatherFootnotes);
//# sourceMappingURL=gather-footnotes.js.map