mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-12-25 13:58:56 +01:00
UI: fix multiline LaTeX equations
This commit is contained in:
parent
493f8c3242
commit
ffc713f72b
@ -103,12 +103,27 @@ def convert_to_markdown(string):
|
||||
|
||||
result = ''
|
||||
is_code = False
|
||||
is_latex = False
|
||||
for line in string.split('\n'):
|
||||
if line.lstrip(' ').startswith('```'):
|
||||
stripped_line = line.strip()
|
||||
|
||||
if stripped_line.startswith('```'):
|
||||
is_code = not is_code
|
||||
elif stripped_line.startswith('$$'):
|
||||
is_latex = not is_latex
|
||||
elif stripped_line.endswith('$$'):
|
||||
is_latex = False
|
||||
elif stripped_line.startswith('\\\\['):
|
||||
is_latex = True
|
||||
elif stripped_line.startswith('\\\\]'):
|
||||
is_latex = False
|
||||
elif stripped_line.endswith('\\\\]'):
|
||||
is_latex = False
|
||||
|
||||
result += line
|
||||
if is_code or line.startswith('|'): # Don't add an extra \n for tables or code
|
||||
|
||||
# Don't add an extra \n for tables, code, or LaTeX
|
||||
if is_code or is_latex or line.startswith('|'):
|
||||
result += '\n'
|
||||
else:
|
||||
result += '\n\n'
|
||||
|
Loading…
Reference in New Issue
Block a user