You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2022/08/03 15:23:51 UTC
[lucene-jira-archive] branch main updated: reorder text processing, tweak mention format, escape tilde (#108)
This is an automated email from the ASF dual-hosted git repository.
mikemccand pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git
The following commit(s) were added to refs/heads/main by this push:
new c025f114 reorder text processing, tweak mention format, escape tilde (#108)
c025f114 is described below
commit c025f114d7c8548fff803d2b3c8e2d70a29f40ad
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Thu Aug 4 00:23:46 2022 +0900
reorder text processing, tweak mention format, escape tilde (#108)
---
migration/src/jira_util.py | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index b9e6fc04..4931ff64 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -255,17 +255,6 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}, account_map: d
for emoji, unicode in JIRA_EMOJI_TO_UNICODE.items():
text = re.sub(emoji, unicode, text)
- # convert Jira markup into Markdown with customization
- elements = MarkupElements()
- elements.replace(UnorderedList, UnorderedTweakedList)
- elements.replace(OrderedList, OrderedTweakedList)
- elements.replace(BlockQuote, TweakedBlockQuote)
- elements.replace(Quote, TweakedQuote)
- elements.replace(Monospaced, TweakedMonospaced)
- elements.insert_after(Ruler, LongRuler)
- elements.append(EscapeHtmlTag)
- text = jira2markdown.convert(text, elements=elements)
-
# convert @ mentions
mentions = re.findall(REGEX_MENTION_ATMARK, text)
if mentions:
@@ -287,9 +276,23 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}, account_map: d
disp_name = jira_users.get(jira_id)
gh_m = account_map.get(jira_id)
# replace Jira name with GitHub account or Jira display name if it is available, othewise show Jira name with ``
- mention = lambda: f"@{gh_m}" if gh_m else disp_name if disp_name else f"`~{jira_id}`"
+ mention = lambda: f"@{gh_m}" if gh_m else disp_name if disp_name else f"`@{jira_id}`"
text = text.replace(m, mention())
+ # escape tilde to avoid unintentional strike-throughs in Markdown
+ text = text.replace("~", "\~")
+
+ # convert Jira markup into Markdown with customization
+ elements = MarkupElements()
+ elements.replace(UnorderedList, UnorderedTweakedList)
+ elements.replace(OrderedList, OrderedTweakedList)
+ elements.replace(BlockQuote, TweakedBlockQuote)
+ elements.replace(Quote, TweakedQuote)
+ elements.replace(Monospaced, TweakedMonospaced)
+ elements.insert_after(Ruler, LongRuler)
+ elements.append(EscapeHtmlTag)
+ text = jira2markdown.convert(text, elements=elements)
+
# convert links to attachments
text = re.sub(REGEX_LINK, repl_att, text)