From dac2d14380b83ffe9deee57d0b58a96414be6704 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Sat, 1 Jul 2023 01:20:58 -0700 Subject: [PATCH] Handle file names appropriately for md files and render commits in github results --- src/khoj/interface/web/index.html | 3 ++- src/khoj/processor/markdown/markdown_to_jsonl.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/khoj/interface/web/index.html b/src/khoj/interface/web/index.html index 5c7f8790..fca3b858 100644 --- a/src/khoj/interface/web/index.html +++ b/src/khoj/interface/web/index.html @@ -70,7 +70,8 @@ } else if ( item.additional.file.endsWith(".md") || item.additional.file.endsWith(".markdown") || - (item.additional.file.includes("issues") && item.additional.file.includes("github.com")) + (item.additional.file.includes("issues") && item.additional.file.includes("github.com")) || + (item.additional.file.includes("commit") && item.additional.file.includes("github.com")) ) { html += render_markdown(query, [item]); diff --git a/src/khoj/processor/markdown/markdown_to_jsonl.py b/src/khoj/processor/markdown/markdown_to_jsonl.py index c15ee732..e7eae240 100644 --- a/src/khoj/processor/markdown/markdown_to_jsonl.py +++ b/src/khoj/processor/markdown/markdown_to_jsonl.py @@ -147,12 +147,13 @@ class MarkdownToJsonl(TextToJsonl): if type(raw_filename) == str and re.search(r"^https?://", raw_filename): entry_filename = raw_filename else: - entry_filename = Path(raw_filename) + 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"# {entry_filename.stem}\n#" if heading else f"# {entry_filename.stem}\n" + prefix = f"# {stem}\n#" if heading else f"# {stem}\n" compiled_entry = f"{prefix}{parsed_entry}" entries.append( Entry(