const code = document.getElementsByTagName("pre")[0] const fixPath = p => p.replace("/", "_") const term = t => t .replaceAll(/(\([+-][0-9]+[ubt]?\))/g, "$1") .replaceAll(/(?)(\()/g, "(") .replaceAll(/(\))(?!\<)/g, ")") .replaceAll("[", "[") .replaceAll("]", "]") .replaceAll(/(?$1") code.innerHTML = code.innerHTML .replaceAll(/^:import std\/(.*) (.*)$/gm, (_, p, s) => `:import std/${p} ${s}`) .replaceAll(/^:input std\/(.*)$/gm, (_, p) => `:input std/${p}`) .replaceAll(/^:test \((.*)\) \((.*)\)$/gm, (_, t1, t2) => `:test (${term(t1)}) (${term(t2)})`) .replaceAll(/^([^:\n<#][^ ]*) (.*)$/gm, (_, d, t) => `${d} ${term(t)}`) .replaceAll(/^# (.*)$/gm, "# $1") .replaceAll(/ ⧗ (.*)\n/g, " ⧗ $1\n") code.innerHTML = `${code.innerHTML}` const lines = code.innerHTML.split(/\n/).length - 1 for (let i = 0; i < lines; i++) { const cur = code.getElementsByTagName("span")[0] cur.innerHTML += `${i + 1}` }