From c05161eb4a36796afa26b1c49c0beedb1dda2af4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?benjamin=20melan=C3=A7on?= Date: Sat, 22 Jun 2024 23:02:26 -0400 Subject: [PATCH] Remove all Zim wiki boilerplate In our case it happens to always be identical --- zimwiki_txt_to_logseq_md.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/zimwiki_txt_to_logseq_md.py b/zimwiki_txt_to_logseq_md.py index 5856591..5d82b53 100644 --- a/zimwiki_txt_to_logseq_md.py +++ b/zimwiki_txt_to_logseq_md.py @@ -2,9 +2,22 @@ import os def rewrite_file(filepath): with open(filepath, 'r') as f: - contents = f.read() + base = filepath[:-4] + newfilepath = base + ".md" + with open(newfilepath, 'w') as w: + for i, line in enumerate(f): + if ( (i == 0 and line == "Content-Type: text/x-zim-wiki\n") + or (i == 1 and line == "Wiki-Format: zim 0.26\n") + or (i == 2 and line == "Creation-Date: Not found\n") + or (i == 3 and line == "Modification-Date: Not found\n") + or (i == 4 and line == "\n") + ): + continue + + w.write(line) -for filepath in os.listdir(): - if file.endswith(".txt"): - rewrite_file(filepath) + +# for filepath in os.listdir(): +# if file.endswith(".txt"): +# rewrite_file(filepath)