Explorar o código

Add **bold** support in chat mode

oobabooga %!s(int64=3) %!d(string=hai) anos
pai
achega
dfbca86533
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      modules/html_generator.py

+ 2 - 2
modules/html_generator.py

@@ -242,8 +242,8 @@ def generate_chat_html(history, name1, name2, character):
 
     for i,_row in enumerate(history[::-1]):
         row = _row.copy()
-        row[0] = re.sub(r"[\\]*\*", r"*", row[0])
-        row[1] = re.sub(r"[\\]*\*", r"*", row[1])
+        row[0] = re.sub(r"(\*\*)([^\*\n]*)(\*\*)", r"<b>\2</b>", row[0])
+        row[1] = re.sub(r"(\*\*)([^\*\n]*)(\*\*)", r"<b>\2</b>", row[1])
         row[0] = re.sub(r"(\*)([^\*\n]*)(\*)", r"<em>\2</em>", row[0])
         row[1] = re.sub(r"(\*)([^\*\n]*)(\*)", r"<em>\2</em>", row[1])
         p = '\n'.join([f"<p>{x}</p>" for x in row[1].split('\n')])