-
Notifications
You must be signed in to change notification settings - Fork 9
Closed
Description
Hey @hvalev. I found some weird behavior when table contains unicode emoji symbols. When table column contains emoji then markdown_table adds extra space which prevents table to be rendered correctly.. using emoji_spacing="mono" helps sometimes, but sometimes not. I can't figure out logic myself to fix it and send PR. Would be great if you can take a look.
Consider following example
from py_markdown_table.markdown_table import markdown_table
multiline_format = {"column_1": 10, "column_2": 40, "column_3": 40}
rows = [
{"column_1": "question 2", "column_2": "🔴 FAIL", "column_3": "comment"},
{"column_1": "question 1", "column_2": "🟢 PASS", "column_3": "comment"},
]
tbl = markdown_table(rows)
tbl.set_params(
row_sep="always",
multiline_delimiter=" ",
padding_weight="right",
quote=False,
multiline=multiline_format,
emoji_spacing = None
)
tbl_str = tbl.get_markdown()
print(tbl_str)Notice that row 2 and 3 has extra space in column 2 and table can't be rendered correctly (pandoc -f markdown -t html5 -o output.html test.md):
+----------+----------------------------------------+----------------------------------------+
|column_1 |column_2 |column_3 |
+----------+----------------------------------------+----------------------------------------+
|question 2|🔴 FAIL |comment |
+----------+----------------------------------------+----------------------------------------+
|question 1|🟢 PASS |comment |
+----------+----------------------------------------+----------------------------------------+
WIth emoji_spacing="mono" row 2 rendered correctly, but row 3 is not..
tbl = markdown_table(rows)
tbl.set_params(
row_sep="always",
multiline_delimiter=" ",
padding_weight="right",
quote=False,
multiline=multiline_format,
emoji_spacing="mono"
)
tbl_str = tbl.get_markdown()
print(tbl_str)+----------+----------------------------------------+----------------------------------------+
|column_1 |column_2 |column_3 |
+----------+----------------------------------------+----------------------------------------+
|question 2|🔴 FAIL |comment |
+----------+----------------------------------------+----------------------------------------+
|question 1|🟢 PASS |comment |
+----------+----------------------------------------+----------------------------------------+

Metadata
Metadata
Assignees
Labels
No labels