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/08/13 14:32:14 UTC
[lucene-jira-archive] branch main updated: escape > to avoid wrong quotes in markdown (#146)
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 97981b4e escape > to avoid wrong quotes in markdown (#146)
97981b4e is described below
commit 97981b4e718f61635d00d8ebbae6aebdca62e58d
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Aug 13 23:32:10 2022 +0900
escape > to avoid wrong quotes in markdown (#146)
---
migration/src/jira_util.py | 3 ++-
migration/src/markup/text_effects.py | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index c449bb61..bc613292 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -14,7 +14,7 @@ from jira2markdown.markup.text_breaks import Ruler
from markup.advanced import TweakedCode
from markup.lists import UnorderedTweakedList, OrderedTweakedList
-from markup.text_effects import EscapeHtmlTag, TweakedBlockQuote, TweakedQuote, TweakedMonospaced
+from markup.text_effects import EscapeHtmlTag, EscapeQuoteMD, TweakedBlockQuote, TweakedQuote, TweakedMonospaced
from markup.text_breaks import LongRuler
@@ -340,6 +340,7 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}, account_map: d
elements.replace(Monospaced, TweakedMonospaced)
elements.insert_after(Ruler, LongRuler)
elements.append(EscapeHtmlTag)
+ elements.append(EscapeQuoteMD)
text = jira2markdown.convert(text, elements=elements)
# convert links to attachments
diff --git a/migration/src/markup/text_effects.py b/migration/src/markup/text_effects.py
index 840158ed..178baf84 100644
--- a/migration/src/markup/text_effects.py
+++ b/migration/src/markup/text_effects.py
@@ -7,6 +7,7 @@ from pyparsing import (
StringStart,
SkipTo,
Literal,
+ LineStart,
LineEnd,
Combine,
Literal,
@@ -74,3 +75,14 @@ class EscapeHtmlTag(AbstractMarkup):
@property
def expr(self) -> ParserElement:
return Literal("<").setParseAction(replaceWith("<")) + SkipTo(Literal(">")) + Literal(">").setParseAction(replaceWith(">"))
+
+
+class EscapeQuoteMD(AbstractMarkup):
+ """
+ Escapes '>' at the start of the line that are not a part of any expression grammar
+ """
+
+ @property
+ def expr(self) -> ParserElement:
+ return LineStart() + Literal(">").setParseAction(replaceWith(">"))
+