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/09 07:24:09 UTC

[lucene-jira-archive] branch main updated: Remove extra brackets in {{monospaced}} (#21)

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

tomoko 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 18e448b8 Remove extra brackets in {{monospaced}} (#21)
18e448b8 is described below

commit 18e448b8818f704aa9e259b0a84564c3a4ee80f6
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Jul 9 16:24:05 2022 +0900

    Remove extra brackets in {{monospaced}} (#21)
---
 migration/src/jira_util.py           |  5 +++--
 migration/src/markup/text_effects.py | 18 +++++++++++++-----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index 157803f9..d6db7e17 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -6,10 +6,10 @@ from typing import Optional
 import jira2markdown
 from jira2markdown.elements import MarkupElements
 from jira2markdown.markup.lists import UnorderedList, OrderedList
-from jira2markdown.markup.text_effects import BlockQuote, Quote
+from jira2markdown.markup.text_effects import BlockQuote, Quote, Monospaced
 
 from markup.lists import UnorderedTweakedList, OrderedTweakedList
-from markup.text_effects import TweakedBlockQuote, TweakedQuote
+from markup.text_effects import TweakedBlockQuote, TweakedQuote, TweakedMonospaced
 
 @dataclass
 class Attachment(object):
@@ -207,6 +207,7 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}) -> str:
     elements.replace(OrderedList, OrderedTweakedList)
     elements.replace(BlockQuote, TweakedBlockQuote)
     elements.replace(Quote, TweakedQuote)
+    elements.replace(Monospaced, TweakedMonospaced)
     text = jira2markdown.convert(text, elements=elements)
 
     # markup @ mentions with ``
diff --git a/migration/src/markup/text_effects.py b/migration/src/markup/text_effects.py
index 61f541d7..f180370f 100644
--- a/migration/src/markup/text_effects.py
+++ b/migration/src/markup/text_effects.py
@@ -4,16 +4,11 @@ from pyparsing import (
     ParserElement,
     ParseResults,
     QuotedString,
-    StringEnd,
     StringStart,
     SkipTo,
     Literal,
     LineEnd,
-    Optional,
     Combine,
-    White,
-    OneOrMore,
-    nums,
     replaceWith,
 
 )
@@ -49,3 +44,16 @@ class TweakedQuote(AbstractMarkup):
             Literal("bq. ").setParseAction(replaceWith("> "))
             + SkipTo(LineEnd()) + LineEnd().setParseAction(replaceWith("\n\n")) # needs additional line feed at the end of quotation to preserve indentation
         )
+
+
+class TweakedMonospaced(AbstractMarkup):
+    def action(self, tokens: ParseResults) -> str:
+        # remove extra brackets in {{monospaced}}
+        # e.g. {{{}BooleanScorer{}}}
+        token = re.sub(r"^[{}]+", "", tokens[0])
+        token = re.sub(r"[{}]+$", "", token)
+        return f"`{token}`"
+
+    @property
+    def expr(self) -> ParserElement:
+        return QuotedString("{{", endQuoteChar="}}").setParseAction(self.action)