mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
Add ancestor headings of each org-mode entry to their compiled form
Resolves #85
This commit is contained in:
@@ -100,12 +100,13 @@ class OrgToEntries(TextToEntries):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
todo_str = f"{parsed_entry.todo} " if parsed_entry.todo else ""
|
todo_str = f"{parsed_entry.todo} " if parsed_entry.todo else ""
|
||||||
# Prepend filename as top heading to entry
|
|
||||||
filename = Path(entry_to_file_map[parsed_entry]).stem
|
# Prepend ancestor headings, filename as top heading to entry for context
|
||||||
|
ancestors_trail = " / ".join(parsed_entry.ancestors) or Path(entry_to_file_map[parsed_entry])
|
||||||
if parsed_entry.heading:
|
if parsed_entry.heading:
|
||||||
heading = f"* {filename}\n** {todo_str}{parsed_entry.heading}."
|
heading = f"* Path: {ancestors_trail}\n** {todo_str}{parsed_entry.heading}."
|
||||||
else:
|
else:
|
||||||
heading = f"* {filename}."
|
heading = f"* Path: {ancestors_trail}."
|
||||||
|
|
||||||
compiled = heading
|
compiled = heading
|
||||||
if state.verbose > 2:
|
if state.verbose > 2:
|
||||||
|
|||||||
@@ -45,9 +45,10 @@ def test_configure_heading_entry_to_jsonl(tmp_path):
|
|||||||
assert is_none_or_empty(jsonl_data)
|
assert is_none_or_empty(jsonl_data)
|
||||||
|
|
||||||
|
|
||||||
def test_entry_split_when_exceeds_max_words(tmp_path):
|
def test_entry_split_when_exceeds_max_words():
|
||||||
"Ensure entries with compiled words exceeding max_words are split."
|
"Ensure entries with compiled words exceeding max_words are split."
|
||||||
# Arrange
|
# Arrange
|
||||||
|
tmp_path = "/tmp/test.org"
|
||||||
entry = f"""*** Heading
|
entry = f"""*** Heading
|
||||||
\t\r
|
\t\r
|
||||||
Body Line
|
Body Line
|
||||||
@@ -55,7 +56,7 @@ def test_entry_split_when_exceeds_max_words(tmp_path):
|
|||||||
data = {
|
data = {
|
||||||
f"{tmp_path}": entry,
|
f"{tmp_path}": entry,
|
||||||
}
|
}
|
||||||
expected_heading = f"* {tmp_path.stem}\n** Heading"
|
expected_heading = f"* Path: {tmp_path}\n** Heading"
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
# Extract Entries from specified Org files
|
# Extract Entries from specified Org files
|
||||||
|
|||||||
Reference in New Issue
Block a user