From ad4fa4b2f4063f41b2a886e4ac2aed24b750553a Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 31 Mar 2024 18:03:17 +0530 Subject: [PATCH] Fix adding file path instead of stem to markdown entries --- src/khoj/processor/content/markdown/markdown_to_entries.py | 5 ++--- tests/test_markdown_to_entries.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/khoj/processor/content/markdown/markdown_to_entries.py b/src/khoj/processor/content/markdown/markdown_to_entries.py index 300b543e..b00ac325 100644 --- a/src/khoj/processor/content/markdown/markdown_to_entries.py +++ b/src/khoj/processor/content/markdown/markdown_to_entries.py @@ -142,13 +142,12 @@ class MarkdownToEntries(TextToEntries): entry_filename = urllib3.util.parse_url(raw_filename).url else: entry_filename = str(Path(raw_filename)) - stem = Path(raw_filename).stem heading = parsed_entry.splitlines()[0] if re.search("^#+\s", parsed_entry) else "" # Append base filename to compiled entry for context to model # Increment heading level for heading entries and make filename as its top level heading - prefix = f"# {stem}\n#" if heading else f"# {stem}\n" - compiled_entry = f"{entry_filename}\n{prefix}{parsed_entry}" + prefix = f"# {entry_filename}\n#" if heading else f"# {entry_filename}\n" + compiled_entry = f"{prefix}{parsed_entry}" entries.append( Entry( compiled=compiled_entry, diff --git a/tests/test_markdown_to_entries.py b/tests/test_markdown_to_entries.py index 68b6589e..d63f026a 100644 --- a/tests/test_markdown_to_entries.py +++ b/tests/test_markdown_to_entries.py @@ -16,7 +16,7 @@ def test_extract_markdown_with_no_headings(tmp_path): data = { f"{tmp_path}": entry, } - expected_heading = f"# {tmp_path.stem}" + expected_heading = f"# {tmp_path}" # Act # Extract Entries from specified Markdown files