summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/unicode/aliases.txt3
-rw-r--r--modules/unicode/unicode.js24
2 files changed, 26 insertions, 1 deletions
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/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"));
});