Skip to content

Instantly share code, notes, and snippets.

@amb26
Created February 19, 2024 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amb26/e6e301875b30911aa8a93784412ac3b7 to your computer and use it in GitHub Desktop.
Save amb26/e6e301875b30911aa8a93784412ac3b7 to your computer and use it in GitHub Desktop.
/* eslint-env node */
"use strict";
const linkedom = require("linkedom");
const arrow = `
<div class="long-down-arrow">
<svg width="16" height="111">
<use href="#downarrow" />
</svg>
</div>`;
const addArrows = function (document, container) {
const sections = container.querySelectorAll(".section.level2");
console.log("Adding arrows to " + sections.length + " sections");
[...sections].slice(0, -1).forEach(section => {
const node = linkedom.parseHTML(arrow).document.firstElementChild;
section.parentNode.insertBefore(node, section.nextSibling);
});
};
const rewriteTaxonLinks = function (document, container) {
const links = container.querySelectorAll("a");
console.log("Got ", links.length, " links");
link
};
module.exports = {addArrows, rewriteTaxonLinks};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment