fix process_list() function
to handle IndexError exception as well as lines starting with '*' that were not list items.
This commit is contained in:
parent
e364217734
commit
91329e6339
1 changed files with 12 additions and 9 deletions
|
@ -134,15 +134,18 @@ def process_file(ifile: TextIOWrapper):
|
|||
return contents, title
|
||||
|
||||
def process_list(line: str, in_list: bool):
|
||||
if in_list:
|
||||
if line[0] == "*":
|
||||
line = re.sub(r'^\* (.*)', r'<li>\1</li>', line)
|
||||
else:
|
||||
in_list = False
|
||||
line = "</ul>\n\n"
|
||||
elif line[0] == "*":
|
||||
line = "<ul>\n" + re.sub(r'^\* (.*)', r'<li>\1</li>', line)
|
||||
in_list = True
|
||||
try:
|
||||
if in_list:
|
||||
if line[:2] == "* ":
|
||||
line = re.sub(r'^\* (.*)', r'<li>\1</li>', line)
|
||||
else:
|
||||
in_list = False
|
||||
line = f"</ul>\n\n{line}"
|
||||
elif line[:2] == "* ":
|
||||
line = "<ul>\n" + re.sub(r'^\* (.*)', r'<li>\1</li>', line)
|
||||
in_list = True
|
||||
except IndexError:
|
||||
in_list = False
|
||||
return line, in_list
|
||||
|
||||
def process_inline(line: str):
|
||||
|
|
Loading…
Reference in a new issue