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:07:54 UTC
[lucene-jira-archive] 01/01: remove extra brackets in {{monospaced}}
This is an automated email from the ASF dual-hosted git repository.
tomoko pushed a commit to branch fix-monospace
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git
commit f3bf8ee127c6aeb88f6117ebdc66721499c0acf5
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Jul 9 16:07:41 2022 +0900
remove extra brackets in {{monospaced}}
---
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)