diff --git a/src/gmirator/generate.py b/src/gmirator/generate.py
index 5697b69..b56168d 100644
--- a/src/gmirator/generate.py
+++ b/src/gmirator/generate.py
@@ -134,18 +134,15 @@ def process_file(ifile: TextIOWrapper):
return contents, title
def process_list(line: str, in_list: bool):
- try:
- if in_list:
- if line[:2] == "* ":
- line = re.sub(r'^\* (.*)', r'
\1', line)
- else:
- in_list = False
- line = f"\n\n{line}"
- elif line[:2] == "* ":
- line = "\n" + re.sub(r'^\* (.*)', r'- \1
', line)
- in_list = True
- except IndexError:
- in_list = False
+ if in_list:
+ if line[0] == "*":
+ line = re.sub(r'^\* (.*)', r'- \1
', line)
+ else:
+ in_list = False
+ line = "
\n\n"
+ elif line[0] == "*":
+ line = "\n" + re.sub(r'^\* (.*)', r'- \1
', line)
+ in_list = True
return line, in_list
def process_inline(line: str):
diff --git a/tests/test_generate.py b/tests/test_generate.py
index ae97e22..c69ca57 100644
--- a/tests/test_generate.py
+++ b/tests/test_generate.py
@@ -11,22 +11,14 @@ from gmirator.generate import (
def test_process_file():
pass
-def test_process_list_legit_item():
- test_str = "* this is a list item"
- assert process_list(test_str, True) == (f"- {test_str[2:]}
", True)
- assert process_list(test_str, False) == (f"\n- {test_str[2:]}
", True)
-
-def test_process_list_not_list_items():
+def test_process_list():
test_str = "this is a line outside a list"
- assert process_list(test_str, True) == (f"
\n\n{test_str}", False)
+ assert process_list(test_str, True) == ("
\n\n", False)
assert process_list(test_str, False) == (test_str, False)
- test_str = "*this is NOT a list item*"
- assert process_list(test_str, True) == (f"\n\n{test_str}", False)
- assert process_list(test_str, False) == (f"{test_str}", False)
-
-def test_process_list_empty_line():
- assert process_list("", True) == ("\n\n", False)
- assert process_list("", False) == ("", False)
+ test_str = "* this is a list item"
+ assert process_list(test_str, True) == ("this is a list item", True)
+ assert process_list(test_str, False) == ("\n- this is a list item
", True)
+ pass
def test_process_inline():
assert process_inline("*Hello* ~~world~~!") == "Hello world!"
@@ -42,17 +34,4 @@ def test_repl_url_internal_gmi_url():
assert new_url == '=> title
\n'
def test_repl_heading():
- line = "# this is h1 title"
- html_h1 = re.sub(r'^(#+) (.*)', repl_heading, line)
- line = "## this is h2 title"
- html_h2 = re.sub(r'^(#+) (.*)', repl_heading, line)
- line = "### this is h3 title"
- html_h3 = re.sub(r'^(#+) (.*)', repl_heading, line)
- assert html_h1 == "# this is h1 title
"
- assert html_h2 == "## this is h2 title
"
- assert html_h3 == "### this is h3 title
"
-
-def test_repl_heading_h4():
- line = "#### this is h4 title"
- html_h4 = re.sub(r'^(#+) (.*)', repl_heading, line)
- assert html_h4 == "#### this is h4 title
"
+ pass