"use strict"; const crypto = require("crypto"); const htmlentities = require("html-entities"); const markdown = require("markdown-it")({ xhtmlOut: true }); const chroma = require("chroma-js"); const markdown_prism = require("markdown-it-prism"); markdown.use(markdown_prism, { init: (Prism) => { Prism.languages.weacmd = { "string": /\<[^>]+?\>/, "function": /^(?:\/\/\S+)\b/m, "number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?%?/i, "operator": /[<>:=\[\]|{}]/, "keyword": /\b(?:[-+]?[zyx])\b/ } } }); function extract_title(line) { return line.match(/#+\s+(.+)\s*/)[1].replace(/^`*|`*$/g, "") } function make_section(acc, cat_current, cats) { let title = extract_title(acc[0]); return { category: cat_current, category_colour: cats.get(cat_current), category_colour_dark: chroma(cats.get(cat_current)) .set("hsl.s", 0.8) .set("hsl.l", "*0.6") .css("hsl"), title: htmlentities.encode(title), slug: title.toLowerCase().replace(/[^a-z0-9-_\s]+/gi, "") .replace(/\s+/g, "-") .replace(/-.*$/, ""), content: markdown.render(acc.slice(1).join("\n")) .replace(/