add a check for empty <li> tags

The Markdown module will sometimes emit nothing when it's confused by
the input syntax; therefore <li></li> is a sign that perhaps something
went wrong.
This commit is contained in:
Eric Seppanen 2022-01-08 18:18:57 -08:00
parent 701b722e75
commit e133bbfc6e
1 changed files with 5 additions and 1 deletions

View File

@ -46,12 +46,16 @@ def render_file(filename):
def check_tags(html, file):
""" Render markdown to html. """
prev_tag = None
for tag in bs4.BeautifulSoup(html, 'html.parser').find_all():
if tag.name not in VALID_TAGS:
tag_str = str(tag)[:50]
warnings.warn(
f'{file}: unrecognized tag {tag.name} in "{tag_str}"')
if tag.name == 'li':
if tag.get_text() == '':
warnings.warn(f'{file}: empty <{tag.name}> tag after {prev_tag}')
prev_tag = tag
def main():
parser = argparse.ArgumentParser()