mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-09-20 10:35:10 +02:00
Unescape inline code blocks
This commit is contained in:
parent
26c5e5e878
commit
feecd8190f
1 changed files with 4 additions and 3 deletions
|
@ -54,9 +54,6 @@ def convert_to_markdown(string):
|
|||
if line.lstrip(' ').startswith('```'):
|
||||
is_code = not is_code
|
||||
|
||||
if is_code:
|
||||
line = html.unescape(line)
|
||||
|
||||
result += line
|
||||
if is_code or line.startswith('|'): # Don't add an extra \n for tables or code
|
||||
result += '\n'
|
||||
|
@ -85,6 +82,10 @@ def convert_to_markdown(string):
|
|||
else:
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue