From 76debe0071fef6865bd0fb79199f53932bf063c0 Mon Sep 17 00:00:00 2001 From: Radu Date: Sat, 26 Aug 2023 17:29:35 -0400 Subject: Write a working version and include licences Support some symbols, arrows, bold, subscript and superscript. --- subscript.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 subscript.py (limited to 'subscript.py') 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 "" 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) -- cgit v1.2.3