From 3fdc1302ecbb5d28458ddef389f5ff839c474ff8 Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 19 Oct 2023 13:10:57 +0200 Subject: [PATCH 1/2] Fix asciidoc alignment Fixes #256. --- tabulate/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabulate/__init__.py b/tabulate/__init__.py index e100c09..5816e05 100644 --- a/tabulate/__init__.py +++ b/tabulate/__init__.py @@ -259,7 +259,7 @@ def make_header_line(is_header, colwidths, colaligns): colwidths, [alignment[colalign] for colalign in colaligns] ) asciidoc_column_specifiers = [ - f"{width:d}{align}" for width, align in asciidoc_alignments + f"{align}{width:d}" for width, align in asciidoc_alignments ] header_list = ['cols="' + (",".join(asciidoc_column_specifiers)) + '"'] From 7a2e5f3dc4b08a7ca85e0ca065daee216b0f0e34 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 13 Sep 2025 18:19:26 +0200 Subject: [PATCH 2/2] Fix asciidoc tests and docs accordingly --- README.md | 2 +- test/test_output.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 223a85a..5bbe252 100644 --- a/README.md +++ b/README.md @@ -501,7 +501,7 @@ format: ```pycon >>> print(tabulate(table, headers, tablefmt="asciidoc")) -[cols="8<,7>",options="header"] +[cols="<8,>7",options="header"] |==== | item | qty | spam | 42 diff --git a/test/test_output.py b/test/test_output.py index 12dfc3a..5837379 100644 --- a/test/test_output.py +++ b/test/test_output.py @@ -2101,7 +2101,7 @@ def test_asciidoc(): "Output: asciidoc with headers" expected = "\n".join( [ - '[cols="11<,11>",options="header"]', + '[cols="<11,>11",options="header"]', "|====", "| strings | numbers ", "| spam | 41.9999 ", @@ -2117,7 +2117,7 @@ def test_asciidoc_headerless(): "Output: asciidoc without headers" expected = "\n".join( [ - '[cols="6<,10>"]', + '[cols="<6,>10"]', "|====", "| spam | 41.9999 ", "| eggs | 451 ",