mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 13:23:15 +00:00
Fix adding file path instead of stem to markdown entries
This commit is contained in:
@@ -142,13 +142,12 @@ class MarkdownToEntries(TextToEntries):
|
|||||||
entry_filename = urllib3.util.parse_url(raw_filename).url
|
entry_filename = urllib3.util.parse_url(raw_filename).url
|
||||||
else:
|
else:
|
||||||
entry_filename = str(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 ""
|
heading = parsed_entry.splitlines()[0] if re.search("^#+\s", parsed_entry) else ""
|
||||||
# Append base filename to compiled entry for context to model
|
# Append base filename to compiled entry for context to model
|
||||||
# Increment heading level for heading entries and make filename as its top level heading
|
# Increment heading level for heading entries and make filename as its top level heading
|
||||||
prefix = f"# {stem}\n#" if heading else f"# {stem}\n"
|
prefix = f"# {entry_filename}\n#" if heading else f"# {entry_filename}\n"
|
||||||
compiled_entry = f"{entry_filename}\n{prefix}{parsed_entry}"
|
compiled_entry = f"{prefix}{parsed_entry}"
|
||||||
entries.append(
|
entries.append(
|
||||||
Entry(
|
Entry(
|
||||||
compiled=compiled_entry,
|
compiled=compiled_entry,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ def test_extract_markdown_with_no_headings(tmp_path):
|
|||||||
data = {
|
data = {
|
||||||
f"{tmp_path}": entry,
|
f"{tmp_path}": entry,
|
||||||
}
|
}
|
||||||
expected_heading = f"# {tmp_path.stem}"
|
expected_heading = f"# {tmp_path}"
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
# Extract Entries from specified Markdown files
|
# Extract Entries from specified Markdown files
|
||||||
|
|||||||
Reference in New Issue
Block a user