From 4dde3eb8c2961a8361c223a1c81b8f9fc29c44b0 Mon Sep 17 00:00:00 2001
From: arctus-io <58351481+arctus-io@users.noreply.github.com>
Date: Fri, 27 Sep 2024 12:34:59 -0400
Subject: [PATCH 1/2] feat(tables): change table header delimiter to triple
hyphen
---
jira2markdown/markup/tables.py | 2 +-
tests/markup/test_mixed_content.py | 16 ++++++++--------
tests/markup/test_tables.py | 22 +++++++++++-----------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/jira2markdown/markup/tables.py b/jira2markdown/markup/tables.py
index 7a7491f..7785d13 100644
--- a/jira2markdown/markup/tables.py
+++ b/jira2markdown/markup/tables.py
@@ -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"
diff --git a/tests/markup/test_mixed_content.py b/tests/markup/test_mixed_content.py
index 1f9191f..4b0f874 100644
--- a/tests/markup/test_mixed_content.py
+++ b/tests/markup/test_mixed_content.py
@@ -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"]),
],
@@ -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"]:
@@ -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 colored title |\n|-|\n'
+ == '| Table **bold header** and colored title |\n|---|\n'
)
def test_cell_image(self):
- assert convert("|!image.png|width=300!") == '||\n|-|\n'
+ assert convert("|!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:user@example.com]|") == "||\n|-|\n"
- assert convert("|[-alias-|mailto:user@example.com]|") == "|[~~alias~~](mailto:user@example.com)|\n|-|\n"
+ assert convert("|[mailto:user@example.com]|") == "||\n|---|\n"
+ assert convert("|[-alias-|mailto:user@example.com]|") == "|[~~alias~~](mailto:user@example.com)|\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:
diff --git a/tests/markup/test_tables.py b/tests/markup/test_tables.py
index 2c49da0..22e8a01 100644
--- a/tests/markup/test_tables.py
+++ b/tests/markup/test_tables.py
@@ -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|
"""
@@ -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|
"""
@@ -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|
"""
@@ -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 (
@@ -90,7 +90,7 @@ def test_multiline_text(self):
)
== """
|multi
line
header||
-|-|-|
+|---|---|
|multi
line
row|sibling row|
|open
end
row|
"""
@@ -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
@@ -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"
From bc9cf8ac0cce70934b22a445faf381af589c3aea Mon Sep 17 00:00:00 2001
From: arctus-io <58351481+arctus-io@users.noreply.github.com>
Date: Fri, 27 Sep 2024 12:35:16 -0400
Subject: [PATCH 2/2] docs(readme): update table header conversion docs
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index fc387fc..fa1cca6 100644
--- a/README.md
+++ b/README.md
@@ -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|
```