Skip to content

Commit

Permalink
feat(text-effects): use <u> tag in markdown to convert underline toke (
Browse files Browse the repository at this point in the history
  • Loading branch information
catcombo authored Feb 3, 2023
2 parents 2b46327 + aba9901 commit 64dcf0b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 51 deletions.
2 changes: 1 addition & 1 deletion jira2markdown/markup/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def expr(self) -> ParserElement:
"["
+ Optional(SkipTo("|", fail_on="]").set_results_name("alias") + "|")
+ "mailto:"
+ Word(alphanums + "@.-_").set_results_name("email")
+ Word(alphanums + "@.-_+").set_results_name("email")
+ "]",
).set_parse_action(self.action)

Expand Down
2 changes: 2 additions & 0 deletions jira2markdown/markup/text_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def get_ignore_expr(self) -> ParserElement:

class Underline(QuotedElement):
TOKEN = "+"
QUOTE_CHAR = "<u>"
END_QUOTE_CHAR = "</u>"


class InlineQuote(QuotedElement):
Expand Down
86 changes: 45 additions & 41 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "jira2markdown"
version = "0.3.1"
version = "0.3.2"
description = "Convert text from JIRA markup to Markdown using parsing expression grammars"
authors = ["Evgeniy Krysanov <evgeniy.krysanov@gmail.com>"]
readme = "README.md"
Expand Down
11 changes: 7 additions & 4 deletions tests/markup/test_mixed_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ def test_strikethrough_color(self):
def test_underline_color(self):
assert (
convert("+text {color:blue}+text inside+{color} outside+")
== 'text <font color="blue">text inside</font> outside'
== '<u>text <font color="blue"><u>text inside</u></font> outside</u>'
)
assert (
convert("+text {color:blue}contains+ token{color} outside+")
== 'text <font color="blue">contains+ token</font> outside'
== '<u>text <font color="blue">contains+ token</font> outside</u>'
)

def test_inlinequote_color(self):
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_subscript_mention(self):
("headings", "h2. %s", "## %s"),
("bold", "*%s*", "**%s**"),
("strikethrough", "-%s-", "~~%s~~"),
("underline", "+%s+", "%s"),
("underline", "+%s+", "<u>%s</u>"),
("inlinequote", "??%s??", "<q>%s</q>"),
("superscript", "^%s^", "<sup>%s</sup>"),
("subscript", "~%s~", "<sub>%s</sub>"),
Expand Down Expand Up @@ -486,7 +486,10 @@ def test_list_color_list(self):

class TestLink:
def test_alias_markup(self):
assert convert("[+box@example.com+|mailto:box@example.com]") == "<box@example.com>"
assert (
convert("[+box@example.com+|mailto:box@example.com]") == "[<u>box@example.com</u>](mailto:box@example.com)"
)
assert convert("[box+tag@example.com|mailto:box+tag@example.com]") == "<box+tag@example.com>"

def test_text_markup(self):
assert convert("[Text in -square- brackets]") == "[Text in ~~square~~ brackets]"
Expand Down
8 changes: 4 additions & 4 deletions tests/markup/test_text_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def test_adjacent_tokens(self):

class TestUnderline:
def test_basic_conversion(self):
assert convert("inside +some long+ text") == "inside some long text"
assert convert("inside +some long+ text") == "inside <u>some long</u> text"

def test_line_endings(self):
assert convert("+start string end+") == "start string end"
assert convert("\n+start line end+\n") == "\nstart line end\n"
assert convert("+start string end+") == "<u>start string end</u>"
assert convert("\n+start line end+\n") == "\n<u>start line end</u>\n"

def test_match_start_conditions(self):
assert convert("no + space after start+") == "no + space after start+"
Expand All @@ -79,7 +79,7 @@ def test_match_start_conditions(self):
def test_match_end_conditions(self):
assert convert("+text +") == "+text +"
assert convert("+word+connector") == "+word+connector"
assert convert("+skip +spacing + char+") == "skip +spacing + char"
assert convert("+skip +spacing + char+") == "<u>skip +spacing + char</u>"

def test_multiline(self):
assert convert("+multiline\nunderline+") == "+multiline\nunderline+"
Expand Down

0 comments on commit 64dcf0b

Please sign in to comment.