Added subscript parsing

This commit is contained in:
2022-11-10 09:08:58 -08:00
parent 0c215a5df4
commit bd13b10f76
5 changed files with 20 additions and 8 deletions

View File

@@ -5,6 +5,8 @@ from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit import print_formatted_text as printf
from importlib.metadata import version
import re
style = Style.from_dict({ # type: ignore
# Basic formatting
@@ -108,6 +110,9 @@ def show_greeting():
""
])), style = style)
def remove_sub(s: str):
return re.sub("[₀₁₂₃₄₅₆₈₉]*", "", s)
def base4(n: int):
if n == 0:
return [0]
@@ -119,9 +124,9 @@ def base4(n: int):
def subscript(num: int):
# unicode subscripts ₀₁₂₃
# usually look different than
# the rest, so we'll use base 4.
# unicode subscripts ₀₁₂₃ and ₄₅₆₈₉
# usually look different,
# so we'll use base 4.
qb = base4(num)
sub = {