diff options
-rw-r--r-- | modules/nlen/English-Dutch-mistranslations.json | 3 | ||||
-rw-r--r-- | modules/unicode/aliases.txt | 3 | ||||
-rw-r--r-- | modules/unicode/index.html | 20 | ||||
-rw-r--r-- | modules/unicode/unicode.js | 24 |
4 files changed, 48 insertions, 2 deletions
diff --git a/modules/nlen/English-Dutch-mistranslations.json b/modules/nlen/English-Dutch-mistranslations.json index 675269c..c4f0d2f 100644 --- a/modules/nlen/English-Dutch-mistranslations.json +++ b/modules/nlen/English-Dutch-mistranslations.json @@ -31,5 +31,6 @@ {"nl":"opladen","en":"to upload"}, {"nl":"Breedte-eerst zoekopdracht","en":"Breadth-first search"}, {"nl":"zwevende-punt rekenen","en":"floating-point arithmetic"}, -{"nl":"multikernprocessor","en":"multi-core processor"} +{"nl":"multikernprocessor","en":"multi-core processor"}, +{"nl":"automatisch differentiëren in omgekeerde modus","en":"reverse-mode automatic differentiation"} ] diff --git a/modules/unicode/aliases.txt b/modules/unicode/aliases.txt new file mode 100644 index 0000000..ea23cab --- /dev/null +++ b/modules/unicode/aliases.txt @@ -0,0 +1,3 @@ +0x039B lambda +0x03BB lambda +0x2218 composition diff --git a/modules/unicode/index.html b/modules/unicode/index.html index 781090c..407d6b5 100644 --- a/modules/unicode/index.html +++ b/modules/unicode/index.html @@ -39,6 +39,26 @@ code { padding: 3px; border-radius: 5px; } + +@media (prefers-color-scheme: dark) { + body { + color: #eee; + background-color: #181818; + } + .table > div:nth-child(even) { + background-color: #1b1b1b; + } + .table > div:nth-child(odd) { + background-color: #262626; + } + input[type="text"] { + background-color: #444; + color: #fff; + } + code { + background-color: #252525; + } +} </style> <script> function do_lookup(override) { diff --git a/modules/unicode/unicode.js b/modules/unicode/unicode.js index ab8ad53..4b313fc 100644 --- a/modules/unicode/unicode.js +++ b/modules/unicode/unicode.js @@ -24,6 +24,8 @@ const fTITLECASE = 14; let db = new Map(); // ranges: [{name: String, first: int, last: int}] let ranges = []; +// aliases: [{name: String, code: int}] +let aliases = []; function importDatabase(csv) { // clear the database if necessary @@ -56,6 +58,17 @@ function importDatabase(csv) { } } +function importAliases(lines) { + aliases = []; + for (const line of lines.split("\n")) { + const idx = line.indexOf(" "); + if (idx == -1) continue; + const num = parseInt(line.slice(0, idx)); + const descr = line.slice(idx + 1).toUpperCase(); + aliases.push({name: descr, code: num}); + } +} + function lookupCode(codepoint) { for (const range of ranges) { if (range.first <= codepoint && codepoint <= range.last) { @@ -75,7 +88,14 @@ function searchDescription(text) { for (const row of db.values()) { if (row[fNAME].includes(text)) { result.push(row); - if (result.length >= 200) break; + if (result.length >= 500) return result; + } + } + + for (const row of aliases) { + if (row.name.includes(text)) { + result.push(db.get(row.code)); + if (result.length >= 500) return result; } } @@ -123,6 +143,8 @@ module.exports = function (app, io, moddir) { throw new Error("UnicodeData.txt doesn't exist! Be sure to run ./install_prepare.sh"); } + importAliases(fs.readFileSync(path.join(moddir, "aliases.txt")).toString()); + app.get("/unicode", (req, res) => { res.sendFile(path.join(moddir, "index.html")); }); |