From c6693d4bfd06c4dcad31a3c62e518a00ec79fa90 Mon Sep 17 00:00:00 2001 From: Paul Craig Date: Mon, 16 Dec 2024 10:14:38 -0500 Subject: [PATCH 1/3] Convert single-item lists into paragraphs inside of tds We received some feedback that it is better for accessibility to represent single-item lists as paragraphs instead of giving them all list sementics when they are inside of a table cell. Makes sense to me. Added a function that will do this on import inside of "clean_table_cells". Pros: - it's more performant this way since we are already iterating through tds and ths Cons: - it's not super clear what this function does from the outside (but it doesn't change the spirit of the function) --- bloom_nofos/nofos/nofo.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bloom_nofos/nofos/nofo.py b/bloom_nofos/nofos/nofo.py index 34abb75d..cf5f6aa1 100644 --- a/bloom_nofos/nofos/nofo.py +++ b/bloom_nofos/nofos/nofo.py @@ -1257,6 +1257,42 @@ def unwrap_empty_elements(soup): el.unwrap() +def _convert_single_item_lists_to_paragraphs(soup, cell): + """ + This function mutates the soup! + + Converts single-item lists in a table cell to paragraphs for improved accessibility. + + This function checks if a given table cell (`` or ``) contains exactly one child, + which must be a list (`