From 6da8ef4e62dc68895971a165011ce58d08f0b71c Mon Sep 17 00:00:00 2001 From: Bill Hlavacek Date: Sun, 10 May 2026 17:17:23 -0600 Subject: [PATCH 1/2] Accept trailing whitespace between `\` and newline in line continuations `BNGFile.strip_actions` collapses `\` continuations before stripping action lines, but the regex `r"\\\n"` rejects shapes like method=>"ode",\ which appear in real-world BNGL. BNG2.pl tolerates trailing whitespace between the `\` and the newline; the modelapi parser should too. Fix: loosen the regex to `r"\\[ \t]*\n"`. --- bionetgen/modelapi/bngfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bionetgen/modelapi/bngfile.py b/bionetgen/modelapi/bngfile.py index a601a374..f2cfcc1e 100644 --- a/bionetgen/modelapi/bngfile.py +++ b/bionetgen/modelapi/bngfile.py @@ -150,10 +150,11 @@ def strip_actions(self, model_path, folder) -> str: with open(model_path, "r", encoding="UTF-8") as mf: # read and strip actions mstr = mf.read() - # TODO: Clean this up _a lot_ - # this removes any new line escapes (\ \n) to continue - # to another line, so we can just remove the action lines - mstr = re.sub(r"\\\n", "", mstr) + # Collapse `\` line continuations before stripping action + # lines. BNG2.pl also tolerates trailing whitespace between the + # `\` and the newline (e.g. `method=>"ode",\` is + # valid BNGL); accept the same shape here. + mstr = re.sub(r"\\[ \t]*\n", "", mstr) mlines = mstr.split("\n") stripped_lines = list(filter(lambda x: self._not_action(x), mlines)) # remove spaces, actions don't allow them From cb1df61285a2ef29b756a75aee8a5d42c02a2dd6 Mon Sep 17 00:00:00 2001 From: jrfaeder Date: Mon, 11 May 2026 12:09:57 -0400 Subject: [PATCH 2/2] Trigger GitHub PR status refresh