diff --git a/hide-table-columns.py b/hide-table-columns.py index 46d7f5eba..c946565a1 100644 --- a/hide-table-columns.py +++ b/hide-table-columns.py @@ -8,12 +8,25 @@ def remove_column_from_tables(file_path): with open(file_path, 'r', encoding='utf-8') as file: soup = BeautifulSoup(file, 'lxml') + in_context = None + + print("Checking if in valid context for", file_path) + if BUILD_CONTEXT: - context_tag = soup.find('meta', attrs={'name': 'docs-build-context'}) - if context_tag: - if context_tag.get('content') != BUILD_CONTEXT: - print("Not in", context_tag.get('content'), "- skipping", file_path) + context_tags = soup.find('meta', attrs={'name': 'docs-build-context'}) + if context_tags: + for context_tag in context_tags.get('content').split(","): + if context_tag == BUILD_CONTEXT: + in_context = True + print(" ... in", context_tag, "- Processing") + break + else: + print(" ... not in", context_tag) + + if not in_context: return + else: + print("docs-build-context not set. Treating", BUILD_CONTEXT, "as valid.") # Find column to delete column_tag = soup.find('meta', attrs={'name': 'remove-column-from-html-table'}) @@ -26,7 +39,8 @@ def remove_column_from_tables(file_path): # Remove empty rows? row_tag = soup.find('meta', attrs={'name': 'remove-column-emptied-row'}) if row_tag: - empty_rows = 1 + if row_tag.get('content') == 1: + empty_rows = 1 else: empty_rows = 0