Improved message markup handling
This commit is contained in:
parent
3b8700c197
commit
fbb58eb7b9
|
@ -566,6 +566,15 @@ class SidebandApp(MDApp):
|
|||
fn_italic=fb_path+"NotoSans-Italic.ttf",
|
||||
fn_bolditalic=fb_path+"NotoSans-BoldItalic.ttf")
|
||||
|
||||
LabelBase.register(name="mono",
|
||||
fn_regular=fb_path+"RobotoMonoNerdFont-Regular.ttf")
|
||||
|
||||
LabelBase.register(name="term",
|
||||
fn_regular=fb_path+"BigBlueTerm437NerdFont-Regular.ttf")
|
||||
|
||||
LabelBase.register(name="nf",
|
||||
fn_regular=fb_path+"RobotoMonoNerdFont-Regular.ttf")
|
||||
|
||||
def update_input_language(self):
|
||||
language = self.sideband.config["input_language"]
|
||||
if language == None:
|
||||
|
|
|
@ -86,14 +86,8 @@ def multilingual_markup(data):
|
|||
if rfont != "default":
|
||||
do += "[/font]"
|
||||
|
||||
# TODO: Remove
|
||||
# print(do+"\n\n"+str(time.time()-ts))
|
||||
|
||||
return do.encode("utf-8")
|
||||
|
||||
font_map = {
|
||||
"mono": "RobotoMono-Regular"
|
||||
}
|
||||
|
||||
codepoint_map = {
|
||||
0x0590: [0x05ff, "hebrew"],
|
||||
|
|
|
@ -656,7 +656,12 @@ class Messages():
|
|||
def cbf(w):
|
||||
def x(dt):
|
||||
if w.texture_size[0] == 0 and w.texture_size[1] == 0:
|
||||
w.text = "[i]This message could not be rendered, likely due to an error in its markup. Falling back to plain-text rendering.[/i]\n\n"+escape_markup(w.text)
|
||||
w.markup = False
|
||||
escaped_content = escape_markup(w.text)
|
||||
def deferred(dt):
|
||||
w.text = "[i]This message could not be rendered correctly, likely due to an error in its markup. Falling back to plain-text rendering.[/i]\n\n"+escaped_content
|
||||
w.markup = True
|
||||
Clock.schedule_once(deferred, 0.1)
|
||||
return x
|
||||
|
||||
Clock.schedule_once(cbf(item.ids.content_text), 0.25)
|
||||
|
|
Loading…
Reference in New Issue