[llvm] [Github] Improve formating of PR diffs in bot notifications (PR #66118)

Vlad Serebrennikov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 00:04:14 PDT 2023


================
@@ -47,6 +47,21 @@ def _get_curent_team(team_name, teams) -> Optional[github.Team.Team]:
     return None
 
 
+def escape_description(str):
+    # https://github.com/github/markup/issues/1168#issuecomment-494946168
+    str = html.escape(str, False)
+    # '@' followed by alphanum is a user name
+    str = re.sub("@(?=\w+)", "@<!-- -->", str)
+    # '#' followed by digits is considered an issue number
+    str = re.sub("#(?=\d+\s)", "#<!-- -->", str)
+    return str
+
+
+def sanitize_markdown_code_block(str):
+    # remove codeblocks terminators
+    return re.sub("^\s*```\s*$", r"` ` `", str)
----------------
Endilll wrote:

Ah, I though you match both opening and closing triple backticks.
But is this going to work correctly for multiple code blocks in a message? Multiple unescaped openings might be interpreted as opening and closing.

https://github.com/llvm/llvm-project/pull/66118


More information about the llvm-commits mailing list