mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 01:09:22 +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 = ''
|
result = ''
|
||||||
is_code = False
|
is_code = False
|
||||||
|
is_latex = False
|
||||||
for line in string.split('\n'):
|
for line in string.split('\n'):
|
||||||
if line.lstrip(' ').startswith('```'):
|
stripped_line = line.strip()
|
||||||
|
|
||||||
|
if stripped_line.startswith('```'):
|
||||||
is_code = not is_code
|
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
|
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'
|
result += '\n'
|
||||||
else:
|
else:
|
||||||
result += '\n\n'
|
result += '\n\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user