Skip to content

Commit

Permalink
feat(tables): change table header delimiter to triple hyphen
Browse files Browse the repository at this point in the history
  • Loading branch information
arctus-io authored Sep 27, 2024
1 parent decc031 commit 4dde3eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion jira2markdown/markup/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def action(self, tokens: ParseResults) -> str:
output[0] += "|" * (max_columns_count - len(lines[0]))

# Insert header delimiter after the first row
output.insert(1, "|" + "-|" * max(max_columns_count, 1))
output.insert(1, "|" + "---|" * max(max_columns_count, 1))

return "\n".join(output) + "\n"

Expand Down
16 changes: 8 additions & 8 deletions tests/markup/test_mixed_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_mention(self, token, test_input, expected):
[
("blockquote", "{quote}%s{quote}", ["> %s", "> %s"]),
("panel", "{panel}%s{panel}", ["> %s", "> %s"]),
("table", "|%s\n|row", ["|%s|\n|-|\n|row|\n"]),
("table", "|%s\n|row", ["|%s|\n|---|\n|row|\n"]),
("unordered_list", "* %s", ["- %s", " %s"]),
("ordered_list", "# %s", ["1. %s", " %s"]),
],
Expand All @@ -196,7 +196,7 @@ def test_table(self, token, test_input, expected):
if token == "table":
pytest.skip(f"Skip nested tests for {token} token")
else:
assert convert(test_input % "|Table") == self.render_expected(expected, "|Table|\n|-|\n")
assert convert(test_input % "|Table") == self.render_expected(expected, "|Table|\n|---|\n")

def test_list(self, token, test_input, expected):
if token in ["unordered_list", "ordered_list"]:
Expand Down Expand Up @@ -254,21 +254,21 @@ class TestTableContent:
def test_basic_markup(self):
assert (
convert("| Table *bold header* and {color:red}colored title{color} |")
== '| Table **bold header** and <font color="red">colored title</font> |\n|-|\n'
== '| Table **bold header** and <font color="red">colored title</font> |\n|---|\n'
)

def test_cell_image(self):
assert convert("|!image.png|width=300!") == '|<img src="image.png" width="300" />|\n|-|\n'
assert convert("|!image.png|width=300!") == '|<img src="image.png" width="300" />|\n|---|\n'

def test_cell_link(self):
assert convert("|[link|http://example.com]|") == "|[link](http://example.com)|\n|-|\n"
assert convert("|[link|http://example.com]|") == "|[link](http://example.com)|\n|---|\n"

def test_cell_mailto(self):
assert convert("|[mailto:[email protected]]|") == "|<[email protected]>|\n|-|\n"
assert convert("|[-alias-|mailto:[email protected]]|") == "|[~~alias~~](mailto:[email protected])|\n|-|\n"
assert convert("|[mailto:[email protected]]|") == "|<[email protected]>|\n|---|\n"
assert convert("|[-alias-|mailto:[email protected]]|") == "|[~~alias~~](mailto:[email protected])|\n|---|\n"

def test_cell_mention(self):
assert convert("|[user|~uuid]|", {"uuid": "elliot"}) == "|@elliot|\n|-|\n"
assert convert("|[user|~uuid]|", {"uuid": "elliot"}) == "|@elliot|\n|---|\n"


class TestPanelContent:
Expand Down
22 changes: 11 additions & 11 deletions tests/markup/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_basic_conversion(self):
)
== """
|header 1|header 2|header 3|
|-|-|-|
|---|---|---|
|cell 1-1|cell 1-2|cell 1-3|
|cell 2-1|cell 2-2|cell 2-3|
"""
Expand All @@ -30,7 +30,7 @@ def test_mixed_column_separator(self):
)
== """
|header 1|header 2|header 3|
|-|-|-|
|---|---|---|
|cell 1-1|cell 1-2|cell 1-3|
|cell 2-1|cell 2-2|cell 2-3|
"""
Expand All @@ -47,7 +47,7 @@ def test_uneven_columns_count(self):
)
== """
|header 1|header 2||
|-|-|-|
|---|---|---|
|cell 1-1|cell 1-2|cell 1-3|
|cell 2-1|
"""
Expand All @@ -64,14 +64,14 @@ def test_open_end_row(self):
)
== """
|header 1|header 2|header 3|
|-|-|-|
|---|---|---|
|cell 1-1|cell 1-2|
|cell 2-1|
"""
)

def test_smallest_table(self):
assert convert("|header") == "|header|\n|-|\n"
assert convert("|header") == "|header|\n|---|\n"

def test_multiline_text(self):
assert (
Expand All @@ -90,7 +90,7 @@ def test_multiline_text(self):
)
== """
|multi<br>line <br>header||
|-|-|
|---|---|
|multi<br>line <br>row|sibling row|
|open <br>end <br>row|
"""
Expand All @@ -110,7 +110,7 @@ def test_table_adjacent_text(self):
text before table
|header 1|header 2|
|-|-|
|---|---|
|cell 1-1|cell 1-2|
text after table
Expand All @@ -130,12 +130,12 @@ def test_empty_rows(self):
)
== """
|text|
|-|
|---|
|end|
"""
)

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"
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"

0 comments on commit 4dde3eb

Please sign in to comment.