소스 검색

Add italics to *actions*

oobabooga 3 년 전
부모
커밋
cf0cdae9c6
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      html_generator.py

+ 5 - 0
html_generator.py

@@ -220,6 +220,11 @@ def generate_chat_html(history, name1, name2):
         img = ''
 
     for row in history[::-1]:
+        row = list(row)
+        row[0] = re.sub(r"[\\]*\*", r"*", row[0])
+        row[1] = re.sub(r"[\\]*\*", r"*", row[1])
+        row[0] = re.sub(r"(\*)([^\*]*)(\*)", r"<em>\2</em>", row[0])
+        row[1] = re.sub(r"(\*)([^\*]*)(\*)", r"<em>\2</em>", row[1])
         p = '\n'.join([f"<p>{x}</p>" for x in row[1].split('\n')])
         output += f"""
               <div class="message">