You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2022/07/30 03:13:35 UTC

[lucene-jira-archive] 01/01: convert jira emojis only when it is preceded and followed by a space character

This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a commit to branch fix-wrong-jira-emoji-conversion
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git

commit 6ffbbf3e01728a85ab0e23ad30590657bdbcacbb
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Jul 30 12:13:25 2022 +0900

    convert jira emojis only when it is preceded and followed by a space character
---
 migration/src/jira_util.py | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index 3653347c..b16f1eff 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -204,24 +204,25 @@ def extract_pull_requests(o: dict) -> list[str]:
     return res
 
 
+# space character + Jira emoji + space character
 JIRA_EMOJI_TO_UNICODE = {
-    "(y)": "\U0001F44D",
-    "(n)": "\U0001F44E",
-    "(i)": "\U0001F6C8",
-    "(/)": "\u2714",
-    "(x)": "\u274C",
-    "(!)": "\u26A0",
-    "(+)": "\u002B",
-    "(-)": "\u2212",
-    "(?)": "\u003F",
-    "(on)": "\U0001F4A1",
-    "(off)": "\U0001F4A1",
-    "(*)": "\u2B50",
-    "(*r)": "\u2B50",
-    "(*g)": "\u2B50",
-    "(*b)": "\u2B50",
-    "(flag)": "\U0001F3F4",
-    "(flagoff)": "\U0001F3F3"
+    "(?<=\s)\(y\)((?=$)|(?=\s))": "\U0001F44D",
+    "(?<=\s)\(n\)((?=$)|(?=\s))": "\U0001F44E",
+    "(?<=\s)\(i\)((?=$)|(?=\s))": "\U0001F6C8",
+    "(?<=\s)\(/\)((?=$)|(?=\s))": "\u2714",
+    "(?<=\s)\(x\)((?=$)|(?=\s))": "\u274C",
+    "(?<=\s)\(\!\)((?=$)|(?=\s))": "\u26A0",
+    "(?<=\s)\(\+\)((?=$)|(?=\s))": "\u002B",
+    "(?<=\s)\(\-\)((?=$)|(?=\s))": "\u2212",
+    "(?<=\s)\(\?\)((?=$)|(?=\s))": "\u003F",
+    "(?<=\s)\(on\)((?=$)|(?=\s))": "\U0001F4A1",
+    "(?<=\s)\(off\)((?=$)|(?=\s))": "\U0001F4A1",
+    "(?<=\s)\(\*\)((?=$)|(?=\s))": "\u2B50",
+    "(?<=\s)\(\*r\)((?=$)|(?=\s))": "\u2B50",
+    "(?<=\s)\(\*g\)((?=$)|(?=\s))": "\u2B50",
+    "(?<=\s)\(\*b\)((?=$)|(?=\s))": "\u2B50",
+    "(?<=\s)\(flag\)((?=$)|(?=\s))": "\U0001F3F4",
+    "(?<=\s)\(flagoff\)((?=$)|(?=\s))": "\U0001F3F3"
 }
 
 REGEX_CRLF = re.compile(r"\r\n")
@@ -245,7 +246,7 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}, account_map: d
 
     # convert Jira special emojis into corresponding or similar Unicode characters
     for emoji, unicode in JIRA_EMOJI_TO_UNICODE.items():
-        text = text.replace(emoji, unicode)
+        text = re.sub(emoji, unicode, text)
 
     # convert Jira markup into Markdown with customization
     elements = MarkupElements()