honkit
Version:
HonKit is building beautiful books using Markdown.
27 lines (24 loc) • 747 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const github_slugid_1 = __importDefault(require("github-slugid"));
const editHTMLElement_1 = __importDefault(require("./editHTMLElement"));
/**
Add ID to an heading
@param {HTMLElement} heading
*/
function addId(heading) {
if (heading.attr("id"))
return;
heading.attr("id", (0, github_slugid_1.default)(heading.text()));
}
/**
Add ID to all headings
@param {HTMLDom} $
*/
function addHeadingId($) {
return (0, editHTMLElement_1.default)($, "h1,h2,h3,h4,h5,h6", addId);
}
exports.default = addHeadingId;