Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed table separator from single-hyphen (-) to triple-hyphen (---) #30

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ convert("[Winston Smith|~accountid:internal-id] woke up with the word 'Shakespea

```
|heading 1|heading 2|heading 3|
|-|-|-|
|---|---|---|
|col A1|col A2|col A3|
|col B1|col B2|col B3|
```
Expand Down
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"
Loading