diff --git a/app/labs/lab_schema.py b/app/labs/lab_schema.py index 1de43ae..f0e932f 100644 --- a/app/labs/lab_schema.py +++ b/app/labs/lab_schema.py @@ -131,14 +131,16 @@ def html_tags(value: str) -> str: if "<" not in value: return value # Remove self closing tags - value = ( + value_stripped = ( re.sub(r'(<.*?/>)|()', '', value, flags=re.MULTILINE) .replace('
', '') .replace('
', '') ) # Enumerate open/close tags - open_tags = re.findall(r'<[^/][\s\S]*?>', value, flags=re.MULTILINE) - close_tags = re.findall(r'', value, flags=re.MULTILINE) + open_tags = re.findall( + r'<[^/][\s\S]*?>', value_stripped, flags=re.MULTILINE) + close_tags = re.findall( + r'', value_stripped, flags=re.MULTILINE) assert len(open_tags) == len(close_tags), ( f'Unclosed HTML tag in section content:\n{value}') return value