aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-05 09:40:54 +0200
committerDanilo M. <danix@danix.xyz>2026-10-05 09:40:54 +0200
commitf245da0551039fffea1f5fde4ced5b59c32500d7 (patch)
treed39e0d18dcf4273d804e082f12c9638b9b21cec4
parenta9cb9970bb30b3b23f308728a38634518c5b0747 (diff)
downloadfanfictioner-f245da0551039fffea1f5fde4ced5b59c32500d7.tar.gz
fanfictioner-f245da0551039fffea1f5fde4ced5b59c32500d7.zip
Strip trailing bold markers from plan fields
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rwxr-xr-xfanfictioner6
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"]]