Fix table header.

Make table header vertical only if at least one of the header cells is
wider than 2 characters.
This commit is contained in:
Sergey Vartanov 2022-01-18 23:51:55 +03:00
parent 1de408ec9a
commit 7fedf63af6

View file

@ -78,12 +78,19 @@ class WikiTable:
if not self.collection.column_values:
self.collection.column_values = [""]
else:
make_vertical: bool = False
for column_value in self.collection.column_values:
if column_value and len(column_value) > 2:
make_vertical = True
for column_value in self.collection.column_values:
text += " ||"
if column_value:
text += (
f" {{{{vert header|{{{{TagValue|"
f"{self.collection.column_key}|{column_value}}}}}}}}}"
tag: str = (
f"{{{{TagValue|"
f"{self.collection.column_key}|{column_value}}}}}"
)
text += " " + (
f"{{{{vert header|{tag}}}}}" if make_vertical else tag
)
text += "\n"