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/31 06:16:08 UTC

[lucene-jira-archive] branch main updated: escape HTML tag chars in inline quotes (#100)

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 d75049a5 escape HTML tag chars in inline quotes (#100)
d75049a5 is described below

commit d75049a58312fcaab038f34d56cec97a0d434b81
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sun Jul 31 15:16:04 2022 +0900

    escape HTML tag chars in inline quotes (#100)
---
 migration/src/markup/text_effects.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/migration/src/markup/text_effects.py b/migration/src/markup/text_effects.py
index a59636e4..840158ed 100644
--- a/migration/src/markup/text_effects.py
+++ b/migration/src/markup/text_effects.py
@@ -38,11 +38,18 @@ class TweakedBlockQuote(AbstractMarkup):
 class TweakedQuote(AbstractMarkup):
     is_inline_element = False
 
+    def action(self, tokens: ParseResults) -> str:
+        # escape HTML tag
+        token = tokens[0].replace("<", "&lt;")
+        token = token.replace(">", "&gt;")
+        return token
+
     @property
     def expr(self) -> ParserElement:
         return ("\n" | StringStart()) + Combine(
             Literal("bq. ").setParseAction(replaceWith("> "))
-            + SkipTo(LineEnd()) + LineEnd().setParseAction(replaceWith("\n\n")) # needs additional line feed at the end of quotation to preserve indentation
+            + SkipTo(LineEnd()).setParseAction(self.action)
+            + LineEnd().setParseAction(replaceWith("\n\n")) # needs additional line feed at the end of quotation to preserve indentation
         )