Spaces:
Sleeping
Sleeping
Merge branch 'list'
Browse files- custom.css +10 -0
- utils.py +13 -0
custom.css
CHANGED
@@ -20,6 +20,16 @@
|
|
20 |
transition: all 0.6s;
|
21 |
}
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
/* 亮色 */
|
24 |
@media (prefers-color-scheme: light) {
|
25 |
#chuanhu_chatbot {
|
|
|
20 |
transition: all 0.6s;
|
21 |
}
|
22 |
|
23 |
+
ol, ul {
|
24 |
+
list-style-position: inside;
|
25 |
+
padding-left: 0;
|
26 |
+
}
|
27 |
+
|
28 |
+
li, ul li {
|
29 |
+
padding-left: 1.5em;
|
30 |
+
text-indent: -1.5em;
|
31 |
+
}
|
32 |
+
|
33 |
/* 亮色 */
|
34 |
@media (prefers-color-scheme: light) {
|
35 |
#chuanhu_chatbot {
|
utils.py
CHANGED
@@ -8,6 +8,7 @@ import datetime
|
|
8 |
import hashlib
|
9 |
import csv
|
10 |
import requests
|
|
|
11 |
|
12 |
import gradio as gr
|
13 |
from pypinyin import lazy_pinyin
|
@@ -40,13 +41,25 @@ def count_token(message):
|
|
40 |
|
41 |
def parse_text(text):
|
42 |
in_code_block = False
|
|
|
43 |
new_lines = []
|
44 |
for line in text.split("\n"):
|
45 |
if line.strip().startswith("```"):
|
46 |
in_code_block = not in_code_block
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
if in_code_block:
|
48 |
if line.strip() != "":
|
49 |
new_lines.append(line)
|
|
|
|
|
|
|
50 |
else:
|
51 |
new_lines.append(line)
|
52 |
if in_code_block:
|
|
|
8 |
import hashlib
|
9 |
import csv
|
10 |
import requests
|
11 |
+
import re
|
12 |
|
13 |
import gradio as gr
|
14 |
from pypinyin import lazy_pinyin
|
|
|
41 |
|
42 |
def parse_text(text):
|
43 |
in_code_block = False
|
44 |
+
in_list = False
|
45 |
new_lines = []
|
46 |
for line in text.split("\n"):
|
47 |
if line.strip().startswith("```"):
|
48 |
in_code_block = not in_code_block
|
49 |
+
else:
|
50 |
+
if re.match(r'(\*|-|\d+\.)\s', line):
|
51 |
+
if not in_list:
|
52 |
+
in_list = True
|
53 |
+
elif in_list and line.strip() != "":
|
54 |
+
in_list = False
|
55 |
+
new_lines.append("")
|
56 |
+
|
57 |
if in_code_block:
|
58 |
if line.strip() != "":
|
59 |
new_lines.append(line)
|
60 |
+
elif in_list:
|
61 |
+
if line.strip() != "":
|
62 |
+
new_lines.append(line)
|
63 |
else:
|
64 |
new_lines.append(line)
|
65 |
if in_code_block:
|