From 89e5a1061a3871519031eb1e1a9d62caf64f9703 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Thu, 29 Jul 2021 14:06:03 +0100 Subject: [PATCH] Don't add plaintext files to indexes --- notes2web.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/notes2web.py b/notes2web.py index 4477c9c..517e7f2 100755 --- a/notes2web.py +++ b/notes2web.py @@ -113,9 +113,9 @@ def main(args): print(f"{plaintext_files=}") for filename in plaintext_files: + title = os.path.basename(re.sub(f"^{args.notes.name}", args.output_dir.name, filename)) output_filename = re.sub(f"^{args.notes.name}", args.output_dir.name, filename) + '.html' os.makedirs(os.path.dirname(output_filename), exist_ok=True) - title = os.path.basename(output_filename) html = re.sub(r'\$title\$', title, TEXT_ARTICLE_TEMPLATE_HEAD) html = re.sub(r'\$raw\$', os.path.basename(filename), html) with open(filename) as fp: @@ -158,8 +158,11 @@ def main(args): title = soup.find('title').get_text() except AttributeError: title = path - else: + elif os.path.isdir(fullpath): title = path + else: + # don't add plaintext files to index, since they have a html wrapper + continue if title.strip() == '': title = path