diff options
| -rwxr-xr-x | fanfictioner | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fanfictioner b/fanfictioner index fc5b761..441d77a 100755 --- a/fanfictioner +++ b/fanfictioner @@ -111,10 +111,10 @@ def parse_plan(text): "heading": "" if m else head, "characters": None, "pose": "", "framing": "", "model": ""} plan["pages"].append(cur) elif section is None and (m := re.match(r"[-*\s]*\**(Series|Book|Style)\**:\**\s*(.*)", s)): - plan[m[1].lower()] = m[2].strip() + plan[m[1].lower()] = m[2].strip().strip("*").strip() elif section == "pages" and cur is not None and \ (m := re.match(r"[-*\s]*\**(Characters|Pose|Framing|Model)\**:\**\s*(.*)", s)): - key, val = m[1].lower(), m[2].strip() + key, val = m[1].lower(), m[2].strip().strip("*").strip() if key == "characters": val = [] if val.lower() == "none" else [c.strip() for c in val.split(",") if c.strip()] elif key == "model": @@ -275,6 +275,8 @@ def selftest(): parse_plan(SAMPLE_PLAN.replace("Characters: Mara, Jon, Kit", "Characters: Mara, Mara"))) fenced = parse_plan(SAMPLE_PLAN.replace("They reach the roof at dusk.", "```\nThey reach the roof at dusk.\n---\n```")) assert fenced["pages"][0]["text"] == "They reach the roof at dusk.", fenced + assert parse_plan(SAMPLE_PLAN.replace("Series: Test Series", "**Series: Test Series**"))["series"] == "Test Series" + assert parse_plan(SAMPLE_PLAN.replace("Characters: Mara, Jon, Kit", "**Characters: Mara, Jon**"))["pages"][0]["characters"] == ["Mara", "Jon"] assert edit_groups([]) == [] assert edit_groups(["Mara", "Jon", "Kit"]) == [["Mara", "Jon"], ["Kit"]] assert edit_groups(list("abcd")) == [["a", "b"], ["c", "d"]] |
