diff options
author | Radu <radu@pml4t.net> | 2023-08-26 17:29:35 -0400 |
---|---|---|
committer | Radu <radu@pml4t.net> | 2023-08-27 16:45:36 -0400 |
commit | 76debe0071fef6865bd0fb79199f53932bf063c0 (patch) | |
tree | bfbadb7592e9f2ace3e1f0f9d150d44b9e190f66 /subscript.py |
Write a working version and include licences
Support some symbols, arrows, bold, subscript and superscript.
Diffstat (limited to 'subscript.py')
-rwxr-xr-x | subscript.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/subscript.py b/subscript.py new file mode 100755 index 0000000..1abd38f --- /dev/null +++ b/subscript.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-only + +from sys import stderr + +with open("UnicodeData.txt") as f: + data = f.read() +data = data.split("\n") + +subscripts = {} + + +def line_to_char(line): + return chr(int(line.split(";", 1)[0], 16)) + + +for line in data: + if "SUBSCRIPT" in line: + normal_name = ''.join(line.split(";", 2)[1].split("SUBSCRIPT ", 1)) + if normal_name == "MINUS": + normal_name = "MINUS SIGN" + if normal_name == "ARABIC ALEF": + normal_name = "ARABIC LETTER ALEF" + normal_line = None + for line2 in data: + if ( + (";" + normal_name + ";" in line2 or ";DIGIT " + normal_name + ";" in line2) + and line != line2 + and "<control>" not in line2 + ): + normal_line = line2 + break + if not normal_line: + print("not found:", line, file=stderr) + continue + char = line_to_char(line) + normal = line_to_char(normal_line) + if normal not in subscripts: + subscripts[normal] = char + +subscripts["-"] = subscripts["−"] +subscripts[" "] = " " + +import json + +print("window.unicodeMaps.toSubscript =", json.dumps(subscripts), ";") +print(subscripts, file=stderr) |