From 033c3d6658f396b264cf9e4963383d5ebbcfeb5f Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 20 Jan 2025 14:46:28 +0100 Subject: [PATCH] Unify bbcode sizing across devices with different display densities --- sbapp/main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sbapp/main.py b/sbapp/main.py index 6eb4294..46d4947 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -1543,6 +1543,7 @@ class SidebandApp(MDApp): h3s = int(sp(16)) if not hasattr(self, "pres"): + self.presz = re.compile(r"\[(?:size=\d*?)\]", re.IGNORECASE | re.MULTILINE ) self.pres = [] res = [ [r"\[(?:code|icode).*?\]", f"[font=mono][size={ms}]"], [r"\[\/(?:code|icode).*?\]", "[/size][/font]"], @@ -1563,6 +1564,11 @@ class SidebandApp(MDApp): for r in res: self.pres.append([re.compile(r[0], re.IGNORECASE | re.MULTILINE ), r[1]]) + + size_matches = self.presz.findall(text) + for sm in size_matches: + text = text.replace(sm, f"{sm[:-1]}sp]") + for pr in self.pres: text = pr[0].sub(pr[1], text)