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:58:40 UTC

[lucene-jira-archive] branch fix-ruler created (now fe1f72e4)

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

tomoko pushed a change to branch fix-ruler
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git


      at fe1f72e4 insert line break before rule (dashes)

This branch includes the following new commits:

     new fe1f72e4 insert line break before rule (dashes)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-jira-archive] 01/01: insert line break before rule (dashes)

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomoko pushed a commit to branch fix-ruler
in repository https://gitbox.apache.org/repos/asf/lucene-jira-archive.git

commit fe1f72e49a74b1c9e741899a78afce81242d2b0f
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Sat Jul 9 16:58:29 2022 +0900

    insert line break before rule (dashes)
---
 migration/src/jira_util.py          |  4 ++++
 migration/src/markup/text_breaks.py | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/migration/src/jira_util.py b/migration/src/jira_util.py
index d6db7e17..ac262786 100644
--- a/migration/src/jira_util.py
+++ b/migration/src/jira_util.py
@@ -7,9 +7,12 @@ import jira2markdown
 from jira2markdown.elements import MarkupElements
 from jira2markdown.markup.lists import UnorderedList, OrderedList
 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 TweakedBlockQuote, TweakedQuote, TweakedMonospaced
+from markup.text_breaks import LongRuler
+
 
 @dataclass
 class Attachment(object):
@@ -208,6 +211,7 @@ def convert_text(text: str, att_replace_map: dict[str, str] = {}) -> str:
     elements.replace(BlockQuote, TweakedBlockQuote)
     elements.replace(Quote, TweakedQuote)
     elements.replace(Monospaced, TweakedMonospaced)
+    elements.insert_after(Ruler, LongRuler)
     text = jira2markdown.convert(text, elements=elements)
 
     # markup @ mentions with ``
diff --git a/migration/src/markup/text_breaks.py b/migration/src/markup/text_breaks.py
new file mode 100644
index 00000000..e285202f
--- /dev/null
+++ b/migration/src/markup/text_breaks.py
@@ -0,0 +1,18 @@
+from pyparsing import Literal, LineEnd, ParserElement, StringStart, replaceWith
+
+from jira2markdown.markup.base import AbstractMarkup
+from jira2markdown.markup.text_breaks import LineBreak
+
+
+class LongRuler(AbstractMarkup):
+    is_inline_element = False
+
+    @property
+    def expr(self) -> ParserElement:
+        # Text with dashed below it turns into a heading. To prevent this
+        # add a line break before the dashes.
+        return (
+            ("\n" | StringStart() | LineBreak(**self.init_kwargs).expr)
+            + Literal("-")[5, ...].setParseAction(replaceWith("\n-----"))
+            + LineEnd()
+        )