From c5205320488ca1fe090c0eae8e9b04864a6830c3 Mon Sep 17 00:00:00 2001 From: Paul Craig Date: Fri, 20 Sep 2024 15:30:22 -0400 Subject: [PATCH] Do not add column classes to tables with 2 columns Only do it for tables with 3, 4, or 5 columns. --- CHANGELOG.md | 2 +- bloom_nofos/nofos/nofo.py | 4 +--- bloom_nofos/nofos/test_nofo.py | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a272fccf..78515fbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve ### Changed -- Add default width classes to markdown tables with 2-5 cols +- Add default width classes to markdown tables with 3,4,5 cols - Updated column headers on NOFO index table - "Top" link on nofo_edit page is always visible - Appearing and disappearing was causing issues diff --git a/bloom_nofos/nofos/nofo.py b/bloom_nofos/nofos/nofo.py index d7905ed8..f4e59c23 100644 --- a/bloom_nofos/nofos/nofo.py +++ b/bloom_nofos/nofos/nofo.py @@ -108,9 +108,7 @@ def convert_th(self, el, text, convert_as_inline): def _determine_width_class_from_th_siblings(th_count=0): # Determine the width class based on the number of elements in the first table row width_class = "" - if th_count == 2: - width_class = "w-50" - elif th_count == 3: + if th_count == 3: width_class = "w-33" elif th_count == 4: width_class = "w-25" diff --git a/bloom_nofos/nofos/test_nofo.py b/bloom_nofos/nofos/test_nofo.py index 00f4f3db..e7bffd65 100644 --- a/bloom_nofos/nofos/test_nofo.py +++ b/bloom_nofos/nofos/test_nofo.py @@ -164,9 +164,7 @@ def test_table_1_th(self): def test_table_2_ths(self): html = "
TH 1TH 2
Cell 1Cell 2
" - expected_markdown = ( - "| TH 1 {: .w-50 } | TH 2 {: .w-50 } |\n| --- | --- |\n| Cell 1 | Cell 2 |" - ) + expected_markdown = "| TH 1 | TH 2 |\n| --- | --- |\n| Cell 1 | Cell 2 |" md_body = md(html) self.assertEqual(md_body.strip(), expected_markdown.strip())