~tsileo/microblog.pub-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch

[PATCH] Fix escaping of < and > in code highlighting

João Costa <jdpc557@gmail.com>
Details
Message ID
<20230407131747.633-1-jdpc557@gmail.com>
DKIM signature
missing
Download raw message
Patch: +2 -2
Handles the < an > substitution with &lt; and &gt; in a more generic way.
I tested this in my production instance and found no problems.
---
 app/utils/highlight.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/utils/highlight.py b/app/utils/highlight.py
index 2e60a36..4f22a92 100644
--- a/app/utils/highlight.py
+++ b/app/utils/highlight.py
@@ -39,8 +39,8 @@ def highlight(html: str) -> str:
                lexer = guess_lexer(code_content)

            # Replace the code with Pygment output
            # XXX: the HTML escaping causes issue with Python type annotations
            code_content = code_content.replace(") -&gt; ", ") -> ")
            code_content = code_content.replace("&gt;", ">")
            code_content = code_content.replace("&lt;", "<")
            code.parent.replaceWith(
                BeautifulSoup(
                    phighlight(code_content, lexer, _FORMATTER), "html5lib"
-- 
2.40.0.windows.1
Reply to thread Export thread (mbox)