-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic syntax highlighting to wiki
- Loading branch information
1 parent
ff53e25
commit bd1b669
Showing
13 changed files
with
143 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.com { | ||
color: #ff64bd; | ||
} | ||
|
||
.def { | ||
color: #13dbee; | ||
} | ||
|
||
.comment { | ||
color: #999999; | ||
} | ||
|
||
.type { | ||
color: #ffa120; | ||
} | ||
|
||
.left-abs, .right-abs { | ||
color: #6b82ff; | ||
} | ||
|
||
.left-app, .right-app { | ||
color: #ff8750; | ||
} | ||
|
||
.index { | ||
color: #ff5050; | ||
} | ||
|
||
.number { | ||
color: #b1ee13; | ||
} | ||
|
||
/* lol */ | ||
.string, .string * { | ||
color: #bb73f0 !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// high-quality syntax highlighter | ||
// TODO: Implement actual highlighter (or fix many regex bugs) | ||
|
||
const term = (t) => | ||
t | ||
.replaceAll(/'(.)'/g, "<span class='string'>'$1'</span>") | ||
.replaceAll(/"([^\"]*)"/g, "<span class='string'>\"$1\"</span>") | ||
.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>"); | ||
|
||
const highlightTerm = (elem) => { | ||
elem.innerHTML = term(elem.innerHTML); | ||
}; | ||
|
||
const highlight = (elem) => { | ||
const fixPath = (p) => p.replace("/", "_"); | ||
|
||
elem.innerHTML = elem.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( | ||
/^:time (.*)$/gm, | ||
(_, t) => `<span class='com'>:time</span> ${term(t)}`, | ||
) | ||
.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"); | ||
}; | ||
|
||
window.onload = () => { | ||
[...document.querySelectorAll("code.language-bruijn")].forEach(highlight); | ||
[...document.querySelectorAll("code.bruijn")].forEach(highlightTerm); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters