add markdown table border line to make text boundary more clear
This commit is contained in:
parent
9c15c446a6
commit
6a2c7db7c1
14
main.py
14
main.py
@ -37,8 +37,20 @@ gr.Chatbot.postprocess = format_io
|
|||||||
from theme import adjust_theme
|
from theme import adjust_theme
|
||||||
set_theme = adjust_theme()
|
set_theme = adjust_theme()
|
||||||
|
|
||||||
|
CSS = """
|
||||||
|
.markdown-body table {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.markdown-body th, .markdown-body td {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
cancel_handles = []
|
cancel_handles = []
|
||||||
with gr.Blocks(theme=set_theme, analytics_enabled=False) as demo:
|
with gr.Blocks(theme=set_theme, analytics_enabled=False, css=CSS) as demo:
|
||||||
gr.HTML(title_html)
|
gr.HTML(title_html)
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
with gr.Column(scale=2):
|
with gr.Column(scale=2):
|
||||||
|
@ -158,11 +158,12 @@ def markdown_convertion(txt):
|
|||||||
"""
|
"""
|
||||||
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
将Markdown格式的文本转换为HTML格式。如果包含数学公式,则先将公式转换为HTML格式。
|
||||||
"""
|
"""
|
||||||
|
pre = '<div class="markdown-body">'
|
||||||
|
suf = '</div>'
|
||||||
if ('$' in txt) and ('```' not in txt):
|
if ('$' in txt) and ('```' not in txt):
|
||||||
return markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' + \
|
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + '<br><br>' + markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables']) + suf
|
||||||
markdown.markdown(convert_math(txt, splitParagraphs=False),extensions=['fenced_code','tables'])
|
|
||||||
else:
|
else:
|
||||||
return markdown.markdown(txt,extensions=['fenced_code','tables'])
|
return pre + markdown.markdown(txt,extensions=['fenced_code','tables']) + suf
|
||||||
|
|
||||||
|
|
||||||
def format_io(self, y):
|
def format_io(self, y):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user