Skip to content
Snippets Groups Projects
Commit 49bc07a5 authored by HeJ's avatar HeJ Committed by Roang
Browse files

markdown: handle HTML comments properly

parent e8bfe084
No related branches found
No related tags found
No related merge requests found
...@@ -96,6 +96,9 @@ class MyHtmlRenderer(HTMLRenderer): ...@@ -96,6 +96,9 @@ class MyHtmlRenderer(HTMLRenderer):
@staticmethod @staticmethod
def render_html_span(token): def render_html_span(token):
if token.content.startswith("<!--"):
# HTML comments can be rendered as-is
return token.content
return html.escape(token.content) return html.escape(token.content)
def render_alert_block(self, token: AlertBlock) -> str: def render_alert_block(self, token: AlertBlock) -> str:
...@@ -216,6 +219,9 @@ class MyHtmlRenderer(HTMLRenderer): ...@@ -216,6 +219,9 @@ class MyHtmlRenderer(HTMLRenderer):
class MySanitizedHtmlRenderer(MyHtmlRenderer): class MySanitizedHtmlRenderer(MyHtmlRenderer):
@staticmethod @staticmethod
def render_html_block(token): def render_html_block(token):
if token.content.startswith("<!--"):
# HTML comments can be rendered as-is
return token.content
return html.escape(token.content) return html.escape(token.content)
@staticmethod @staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment