diff options
author | Marvin Borner | 2023-11-11 23:52:05 +0100 |
---|---|---|
committer | Marvin Borner | 2023-11-11 23:52:05 +0100 |
commit | bd1b6690c6847532e59841149b89bc7a8469f586 (patch) | |
tree | 4ed0d168bbee358fb648705dc675d6b1371ee528 /docs/content.js | |
parent | ff53e25945776668d12156193fa5bd7694055174 (diff) |
Added basic syntax highlighting to wiki
Diffstat (limited to 'docs/content.js')
-rw-r--r-- | docs/content.js | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/docs/content.js b/docs/content.js deleted file mode 100644 index f107fc5..0000000 --- a/docs/content.js +++ /dev/null @@ -1,26 +0,0 @@ -const code = document.getElementsByTagName("pre")[0] - -const fixPath = p => p.replace("/", "_") - -const term = t => t - .replaceAll(/(\([+-][0-9]+[ubt]?\))/g, "<span class='number'>$1</span>") - .replaceAll(/(?<!\>)(\()/g, "<span class='left-app'>(</span>") - .replaceAll(/(\))(?!\<)/g, "<span class='right-app'>)</span>") - .replaceAll("[", "<span class='left-abs'>[</span>") - .replaceAll("]", "<span class='right-abs'>]</span>") - .replaceAll(/(?<![+-\d])([0-9])/g, "<span class='index'>$1</span>") - -code.innerHTML = code.innerHTML - .replaceAll(/^:import std\/(.*) (.*)$/gm, (_, p, s) => `<span class="com">:import</span> <a href='${fixPath(p)}.bruijn.html'>std/${p}</a> ${s}`) - .replaceAll(/^:input std\/(.*)$/gm, (_, p) => `<span class="com">:input</span> <a href='${fixPath(p)}.bruijn.html'>std/${p}</a>`) - .replaceAll(/^:test \((.*)\) \((.*)\)$/gm, (_, t1, t2) => `<span class='com'>:test</span> (${term(t1)}) (${term(t2)})`) - .replaceAll(/^([^:\n<#][^ ]*) (.*)$/gm, (_, d, t) => `<span class='def'>${d}</span> ${term(t)}`) - .replaceAll(/^# (.*)$/gm, "<span class='comment'># $1</span>") - .replaceAll(/ ⧗ (.*)\n/g, " ⧗ <span class='type'>$1</span>\n") - -code.innerHTML = `<span class="line"></span>${code.innerHTML}<span class="cl"></span>` -const lines = code.innerHTML.split(/\n/).length - 1 -for (let i = 0; i < lines; i++) { - const cur = code.getElementsByTagName("span")[0] - cur.innerHTML += `<span>${i + 1}</span>` -} |