From 5b16cf6dfd4ed949b67a2ca5091b19893854d68d Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 12 Mar 2022 20:20:54 +0100 Subject: Fix newline issues --- from_old_blog.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'from_old_blog.py') diff --git a/from_old_blog.py b/from_old_blog.py index fc3d698f..8c137530 100644 --- a/from_old_blog.py +++ b/from_old_blog.py @@ -35,7 +35,7 @@ for post in posts: post["post"] = post["post"].encode("iso-8859-1").decode("utf8") post["title"] = post["title"].encode("iso-8859-1").decode("utf8") - post["post"] = post["post"].replace("\\r\\n", "") + post["post"] = post["post"].replace("\\r\\n", " ") t = post["title"] @@ -47,4 +47,6 @@ for post in posts: with open(p, "w") as f: f.write(f"# {t}\n") f.write(f"{y}-{m}-{d}\n\n") - f.write(subprocess.run(["/home/alex/go/bin/html2gmi", "-mn"], input=post["post"].encode("utf8"), stdout=subprocess.PIPE).stdout.decode("utf8")) + gmi = subprocess.run(["/home/alex/go/bin/html2gmi", "-mn"], input=post["post"].encode("utf8"), stdout=subprocess.PIPE).stdout.decode("utf8") + gmi = "\n".join(map(str.rstrip, gmi.splitlines())) + f.write(gmi) -- cgit v1.2.3