Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
bea80a4
1
Parent(s):
7be235d
保留用户输入中的格式
Browse files- overwrites.py +2 -2
- utils.py +3 -0
overwrites.py
CHANGED
@@ -32,7 +32,7 @@ def postprocess(
|
|
32 |
return []
|
33 |
tag_regex = re.compile(r"^<\w+>[^<]+</\w+>")
|
34 |
if tag_regex.search(y[-1][1]):
|
35 |
-
y[-1] = (y[-1][0]
|
36 |
else:
|
37 |
-
y[-1] = (y[-1][0]
|
38 |
return y
|
|
|
32 |
return []
|
33 |
tag_regex = re.compile(r"^<\w+>[^<]+</\w+>")
|
34 |
if tag_regex.search(y[-1][1]):
|
35 |
+
y[-1] = (convert_user(y[-1][0]), y[-1][1])
|
36 |
else:
|
37 |
+
y[-1] = (convert_user(y[-1][0]), convert_mdtext(y[-1][1]))
|
38 |
return y
|
utils.py
CHANGED
@@ -107,6 +107,9 @@ def convert_mdtext(md_text):
|
|
107 |
result = "".join(result)
|
108 |
return result
|
109 |
|
|
|
|
|
|
|
110 |
|
111 |
def detect_language(code):
|
112 |
if code.startswith("\n"):
|
|
|
107 |
result = "".join(result)
|
108 |
return result
|
109 |
|
110 |
+
def convert_user(userinput):
|
111 |
+
userinput = userinput.replace("\n", "<br>")
|
112 |
+
return f"<pre>{userinput}</pre>"
|
113 |
|
114 |
def detect_language(code):
|
115 |
if code.startswith("\n"):
|