mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-26 01:30:20 +01:00
Unescape inline code blocks
This commit is contained in:
parent
26c5e5e878
commit
feecd8190f
@ -54,9 +54,6 @@ def convert_to_markdown(string):
|
|||||||
if line.lstrip(' ').startswith('```'):
|
if line.lstrip(' ').startswith('```'):
|
||||||
is_code = not is_code
|
is_code = not is_code
|
||||||
|
|
||||||
if is_code:
|
|
||||||
line = html.unescape(line)
|
|
||||||
|
|
||||||
result += line
|
result += line
|
||||||
if is_code or line.startswith('|'): # Don't add an extra \n for tables or code
|
if is_code or line.startswith('|'): # Don't add an extra \n for tables or code
|
||||||
result += '\n'
|
result += '\n'
|
||||||
@ -85,6 +82,10 @@ def convert_to_markdown(string):
|
|||||||
else:
|
else:
|
||||||
html_output = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
html_output = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
||||||
|
|
||||||
|
# Unescape code blocks
|
||||||
|
pattern = re.compile(r'<code[^>]*>(.*?)</code>', re.DOTALL)
|
||||||
|
html_output = pattern.sub(lambda x: html.unescape(x.group()), html_output)
|
||||||
|
|
||||||
return html_output
|
return html_output
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user