UNPKG

antora-confluence

Version:

A tool to convert and publish Antora documentation to Confluence

19 lines (18 loc) 643 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const rewriteAnchors = (content) => { const anchors = new Map(); content.querySelectorAll("[id]").forEach((anchor) => { const name = anchor.getAttribute("id"); const anchorTitle = anchor.text; if (name && anchorTitle) { anchors.set(name, anchorTitle); } anchor.insertAdjacentHTML("beforebegin", `<ac:structured-macro ac:name="anchor"><ac:parameter ac:name="">${name}</ac:parameter></ac:structured-macro>`); }); return { anchors, content, }; }; exports.default = rewriteAnchors;