From feecd8190fab73dae0a7c64b546304a22e431c3c Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 24 Aug 2023 21:01:09 -0700 Subject: [PATCH] Unescape inline code blocks --- modules/html_generator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/html_generator.py b/modules/html_generator.py index 86f31f3..47ca609 100644 --- a/modules/html_generator.py +++ b/modules/html_generator.py @@ -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']*>(.*?)', re.DOTALL) + html_output = pattern.sub(lambda x: html.unescape(x.group()), html_output) + return html_output