Skip to content

Commit

Permalink
fix(jira2markdown): process windows line breaks as a Unix line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
catcombo committed Sep 30, 2024
1 parent eac5767 commit 50029e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions jira2markdown/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ def convert(text: str, usernames: Optional[dict] = None, elements: Optional[Mark
inline_markup << elements.expr(inline_markup, markup, usernames, filter(lambda e: e.is_inline_element, elements))
markup << elements.expr(inline_markup, markup, usernames, elements)

text = text.replace("\r\n", "\n")
return markup.transform_string(text)
6 changes: 6 additions & 0 deletions tests/markup/test_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,9 @@ def test_list_indent(self):
1. Three
"""
)

def test_windows_line_breaks(self):
assert (
convert("Line before list\r\n * Bulleted item 1\r\n * Bulleted item 2\r\n\r\nLine after list")
== "Line before list\n- Bulleted item 1\n- Bulleted item 2\n\nLine after list"
)
16 changes: 16 additions & 0 deletions tests/markup/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,19 @@ def test_empty_start_lines(self):
assert convert(" \n|header") == " \n|header|\n|---|\n"
assert convert(" \n \t \n|header") == " \n \t \n|header|\n|---|\n"
assert convert(" \n text \n|header") == " \n text \n\n|header|\n|---|\n"

def test_windows_line_breaks(self):
assert convert(
"text before table:\r\n\r\n"
"||header 1||header 2||header 3||\r\n"
"|cell 1-1|cell 1-2|cell 1-3|\r\n"
"|cell 2-1|cell 2-2|cell 2-3|\r\n\r\n"
"text after table"
) == (
"text before table:\n\n"
"|header 1|header 2|header 3|\n"
"|-|-|-|\n"
"|cell 1-1|cell 1-2|cell 1-3|\n"
"|cell 2-1|cell 2-2|cell 2-3|\n\n"
"text after table"
)

0 comments on commit 50029e0

Please sign in to comment.