mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-22 16:17:57 +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('```'):
|
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'
|
||||||
@ -75,14 +78,14 @@ def convert_to_markdown(string):
|
|||||||
|
|
||||||
result = re.sub(r'(\d+\.)$', r'\g<1> ' + delete_str, result)
|
result = re.sub(r'(\d+\.)$', r'\g<1> ' + delete_str, result)
|
||||||
|
|
||||||
html = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
html_output = markdown.markdown(result, extensions=['fenced_code', 'tables'])
|
||||||
pos = html.rfind(delete_str)
|
pos = html_output.rfind(delete_str)
|
||||||
if pos > -1:
|
if pos > -1:
|
||||||
html = html[:pos] + html[pos + len(delete_str):]
|
html_output = html_output[:pos] + html_output[pos + len(delete_str):]
|
||||||
else:
|
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):
|
def generate_basic_html(string):
|
||||||
|
Loading…
Reference in New Issue
Block a user