From 7fedf63af65d9fecce2afed3751ac4383a6b4a07 Mon Sep 17 00:00:00 2001 From: Sergey Vartanov Date: Tue, 18 Jan 2022 23:51:55 +0300 Subject: [PATCH] Fix table header. Make table header vertical only if at least one of the header cells is wider than 2 characters. --- map_machine/doc/wiki.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/map_machine/doc/wiki.py b/map_machine/doc/wiki.py index d1a0792..c355878 100644 --- a/map_machine/doc/wiki.py +++ b/map_machine/doc/wiki.py @@ -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"