mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 08:07:56 +01:00
Unescape HTML inside code blocks
This commit is contained in:
parent
46408465ce
commit
cebe07f29c
@ -54,6 +54,9 @@ 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'
|
||||
@ -75,14 +78,14 @@ def convert_to_markdown(string):
|
||||
|
||||
result = re.sub(r'(\d+\.)$', r'\g<1> ' + delete_str, result)
|
||||
|
||||
html = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
||||
pos = html.rfind(delete_str)
|
||||
html_output = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
||||
pos = html_output.rfind(delete_str)
|
||||
if pos > -1:
|
||||
html = html[:pos] + html[pos + len(delete_str):]
|
||||
html_output = html_output[:pos] + html_output[pos + len(delete_str):]
|
||||
else:
|
||||
html = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
||||
html_output = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
||||
|
||||
return html
|
||||
return html_output
|
||||
|
||||
|
||||
def generate_basic_html(string):
|
||||
|
Loading…
Reference in New Issue
Block a user