mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 08:07:56 +01:00
UI: fix rendering LaTeX enclosed between \[ and \]
This commit is contained in:
parent
6bab4c2faa
commit
e4d411b841
@ -72,6 +72,14 @@ def replace_blockquote(m):
|
|||||||
@functools.lru_cache(maxsize=None)
|
@functools.lru_cache(maxsize=None)
|
||||||
def convert_to_markdown(string):
|
def convert_to_markdown(string):
|
||||||
|
|
||||||
|
# Make \[ \] LaTeX equations inline
|
||||||
|
pattern = r'^\s*\\\[\s*\n([\s\S]*?)\n\s*\\\]\s*$'
|
||||||
|
replacement = r'\\[ \1 \\]'
|
||||||
|
string = re.sub(pattern, replacement, string, flags=re.MULTILINE)
|
||||||
|
|
||||||
|
# Escape backslashes
|
||||||
|
string = string.replace('\\', '\\\\')
|
||||||
|
|
||||||
# Quote to <q></q>
|
# Quote to <q></q>
|
||||||
string = replace_quotes(string)
|
string = replace_quotes(string)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user