From 014d72f39c3769463ecf4803b6cf7f39a84ea045 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Tue, 24 Aug 2021 15:37:18 +0100 Subject: [PATCH] Fix markdown with no title not displaying in search --- notes2web.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notes2web.py b/notes2web.py index 3494806..7ca6b27 100755 --- a/notes2web.py +++ b/notes2web.py @@ -164,7 +164,7 @@ def main(args): for tag in fm.get('tags'): t = { 'path': str(pathlib.Path(output_filename).relative_to(args.output_dir)), - 'title': fm.get('title') + 'title': fm.get('title') or pathlib.Path(filename).name } if tag in tag_dict.keys(): tag_dict[tag].append(t) @@ -181,7 +181,7 @@ def main(args): all_entries.append({ 'path': str(pathlib.Path(*pathlib.Path(output_filename).parts[1:])), - 'title': fm.get('title'), + 'title': fm.get('title') or pathlib.Path(filename).name, 'tags': fm.get('tags'), 'headers': header_lines }) @@ -284,9 +284,9 @@ def main(args): soup = bs(fp.read(), 'html.parser') try: - title = soup.find('title').get_text() + title = soup.find('title').get_text() or pathlib.Path(path).name except AttributeError: - title = path + title = pathlib.Path(path).stem elif fullpath.is_dir(): title = path else: