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

[lucene-jira-archive] 01/01: escape > to avoid wrong quotes in markdown

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

tomoko pushed a commit to branch escape-quote-mark-md
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git

commit 5cd5c85476d9608dff1291e28d32956bbb8e4ea9
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Aug 13 13:06:59 2022 +0900

    escape > to avoid wrong quotes in markdown
---
 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 513a8100..813a2d7a 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("&lt;")) + SkipTo(Literal(">")) + Literal(">").setParseAction(replaceWith("&gt;"))
+
+
+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("&gt;"))
+