From 60f7f863a75991502c21a16d1a878fce98ad1b93 Mon Sep 17 00:00:00 2001 From: Jayanth Koushik Date: Mon, 10 Jun 2024 11:42:38 -0400 Subject: [PATCH] fix: add code to remove trailing newlines in `make_docs.py` --- src/pyseed.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pyseed.py b/src/pyseed.py index a482878..09e536d 100755 --- a/src/pyseed.py +++ b/src/pyseed.py @@ -1703,11 +1703,13 @@ def main(): print(f"+ {shlex.join(build_cmd)}", file=sys.stderr) subprocess.run(build_cmd, check=True, text=True) +# Remove tralining spaces and newlines from the generated files. for fname in docs_dir.glob("**/*.md"): with open(fname, "r") as f: fdata = f.read() - fdata_fixed = re.sub(r" *(?=\\n|$)", "", fdata) + fdata_fixed = re.sub(r" *(?=$)", "", fdata, flags=re.MULTILINE) + fdata_fixed = re.sub("\\n+(?=$)", "", fdata_fixed) if fdata_fixed != fdata: with open(fname, "w") as f: print(fdata_fixed, file=f)