Remove "Path" prefix from org ancestor heading in compiled entry

This commit is contained in:
Debanjum Singh Solanky 2024-06-06 16:51:26 +05:30
parent dd2225b1aa
commit 18f7e6e7ed
2 changed files with 9 additions and 9 deletions

View file

@ -182,7 +182,7 @@ class OrgToEntries(TextToEntries):
# Children nodes do not need ancestors trail as root parent node will have it
if not entry_heading:
ancestors_trail = " / ".join(parsed_entry.ancestors) or Path(entry_to_file_map[parsed_entry])
heading = f"* Path: {ancestors_trail}\n{heading}" if heading else f"* Path: {ancestors_trail}."
heading = f"* {ancestors_trail}\n{heading}" if heading else f"* {ancestors_trail}."
compiled = heading

View file

@ -50,14 +50,14 @@ def test_entry_split_when_exceeds_max_tokens():
data = {
f"{tmp_path}": entry,
}
expected_heading = f"* Path: {tmp_path}\n** Heading"
expected_heading = f"* {tmp_path}\n** Heading"
# Act
# Extract Entries from specified Org files
entries = OrgToEntries.extract_org_entries(org_files=data)
# Split each entry from specified Org files by max tokens
entries = TextToEntries.split_entries_by_max_tokens(entries, max_tokens=6)
entries = TextToEntries.split_entries_by_max_tokens(entries, max_tokens=5)
# Assert
assert len(entries) == 2
@ -139,7 +139,7 @@ longer body line 2.1
f"{tmp_path}": entry,
}
first_expected_entry = f"""
* Path: {tmp_path}
* {tmp_path}
** Heading 1.
body line 1
@ -148,13 +148,13 @@ longer body line 2.1
""".lstrip()
second_expected_entry = f"""
* Path: {tmp_path}
* {tmp_path}
** Heading 2.
body line 2
""".lstrip()
third_expected_entry = f"""
* Path: {tmp_path} / Heading 2
* {tmp_path} / Heading 2
** Subheading 2.1.
longer body line 2.1
@ -192,7 +192,7 @@ body line 3.1
f"{tmp_path}": entry,
}
first_expected_entry = f"""
* Path: {tmp_path}
* {tmp_path}
** Heading 1.
body line 1
@ -201,7 +201,7 @@ body line 3.1
""".lstrip()
second_expected_entry = f"""
* Path: {tmp_path}
* {tmp_path}
** Heading 2.
body line 2
@ -210,7 +210,7 @@ body line 3.1
""".lstrip()
third_expected_entry = f"""
* Path: {tmp_path}
* {tmp_path}
** Heading 3.
body line 3