diff --git a/modules/html_generator.py b/modules/html_generator.py
index 86f31f3a..47ca6095 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