Spaces:
Running
Running
add markdown table border line to make text boundary more clear
Browse files- main.py +13 -1
- toolbox.py +4 -3
main.py
CHANGED
@@ -37,8 +37,20 @@ gr.Chatbot.postprocess = format_io
|
|
37 |
from theme import adjust_theme
|
38 |
set_theme = adjust_theme()
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
cancel_handles = []
|
41 |
-
with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
42 |
gr.HTML(title_html)
|
43 |
with gr.Row():
|
44 |
with gr.Column(scale=2):
|
|
|
37 |
from theme import adjust_theme
|
38 |
set_theme = adjust_theme()
|
39 |
|
40 |
+
CSS = """
|
41 |
+
.markdown-body table {
|
42 |
+
border: 1px solid #ddd;
|
43 |
+
border-collapse: collapse;
|
44 |
+
}
|
45 |
+
|
46 |
+
.markdown-body th, .markdown-body td {
|
47 |
+
border: 1px solid #ddd;
|
48 |
+
padding: 5px;
|
49 |
+
}
|
50 |
+
"""
|
51 |
+
|
52 |
cancel_handles = []
|
53 |
+
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=CSS) as demo:
|
54 |
gr.HTML(title_html)
|
55 |
with gr.Row():
|
56 |
with gr.Column(scale=2):
|
toolbox.py
CHANGED
@@ -158,11 +158,12 @@ def markdown_convertion(txt):
|
|
158 |
"""
|
159 |
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
160 |
"""
|
|
|
|
|
161 |
if ('$' in txt) and ('```' not in txt):
|
162 |
-
return markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' +
|
163 |
-
markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables'])
|
164 |
else:
|
165 |
-
return markdown.markdown(txt,extensions=['fenced_code','tables'])
|
166 |
|
167 |
|
168 |
def format_io(self, y):
|
|
|
158 |
"""
|
159 |
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
160 |
"""
|
161 |
+
pre = '<div class="markdown-body">'
|
162 |
+
suf = '</div>'
|
163 |
if ('$' in txt) and ('```' not in txt):
|
164 |
+
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' + markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables']) + suf
|
|
|
165 |
else:
|
166 |
+
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + suf
|
167 |
|
168 |
|
169 |
def format_io(self, y):
|