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/11 07:42:52 UTC

[lucene-jira-archive] branch main updated: only escape HTML tags (#32)

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 b00d4fc8 only escape HTML tags (#32)
b00d4fc8 is described below

commit b00d4fc854237423f40c5c8330c51b26e7a100ef
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Mon Jul 11 16:42:48 2022 +0900

    only escape HTML tags (#32)
---
 migration/src/jira_util.py           | 4 ++--
 migration/src/markup/text_effects.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index 3cc916d3..a3a34bf4 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -10,7 +10,7 @@ from jira2markdown.markup.text_effects import BlockQuote, Quote, Monospaced
 from jira2markdown.markup.text_breaks import Ruler
 
 from markup.lists import UnorderedTweakedList, OrderedTweakedList
-from markup.text_effects import EscapeHtml, TweakedBlockQuote, TweakedQuote, TweakedMonospaced
+from markup.text_effects import EscapeHtmlTag, TweakedBlockQuote, TweakedQuote, TweakedMonospaced
 from markup.text_breaks import LongRuler
 
 
@@ -212,7 +212,7 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}, account_map: d
     elements.replace(Quote, TweakedQuote)
     elements.replace(Monospaced, TweakedMonospaced)
     elements.insert_after(Ruler, LongRuler)
-    elements.append(EscapeHtml)
+    elements.append(EscapeHtmlTag)
     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 3a4e87aa..a59636e4 100644
--- a/migration/src/markup/text_effects.py
+++ b/migration/src/markup/text_effects.py
@@ -59,11 +59,11 @@ class TweakedMonospaced(AbstractMarkup):
         return QuotedString("{{", endQuoteChar="}}").setParseAction(self.action)
 
 
-class EscapeHtml(AbstractMarkup):
+class EscapeHtmlTag(AbstractMarkup):
     """
     Escapes HTML characters that are not a part of any expression grammar
     """
 
     @property
     def expr(self) -> ParserElement:
-        return Literal("<").setParseAction(replaceWith("&lt;")) ^ Literal(">").setParseAction(replaceWith("&gt;")) ^ Literal("&").setParseAction(replaceWith("&amp;"))
+        return Literal("<").setParseAction(replaceWith("&lt;")) + SkipTo(Literal(">")) + Literal(">").setParseAction(replaceWith("&gt;"))