mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 05:29:12 +00:00
Add ID, File+Heading based Links to Org-Mode Entries
- Add links to property drawer - This ensures results returned by semantic search contain these links - This allows the user to jump to entry within original file for context - The ID, file+heading based links are more robust to find relevant entry in original file than the line no based link, as edits being done by user to original files between embedding regenerations
This commit is contained in:
@@ -77,7 +77,7 @@ def makelist(filename):
|
||||
deadline_date = ''
|
||||
thisNode.setProperties(propdict)
|
||||
nodelist.append( thisNode )
|
||||
propdict = {'SOURCE': f'file:{filename}::{ctr}'}
|
||||
propdict = {'LINE': f'file:{filename}::{ctr}'}
|
||||
level = hdng.group(1)
|
||||
heading = hdng.group(2)
|
||||
bodytext = ""
|
||||
@@ -114,7 +114,11 @@ def makelist(filename):
|
||||
|
||||
prop_srch = re.search(r'^\s*:(.*?):\s*(.*?)\s*$', line)
|
||||
if prop_srch:
|
||||
propdict[prop_srch.group(1)] = prop_srch.group(2)
|
||||
# Set ID property to an id based org-mode link to the entry
|
||||
if prop_srch.group(1) == 'ID':
|
||||
propdict['ID'] = f'id:{prop_srch.group(2)}'
|
||||
else:
|
||||
propdict[prop_srch.group(1)] = prop_srch.group(2)
|
||||
continue
|
||||
sd_re = re.search(r'SCHEDULED:\s+<([0-9]+)\-([0-9]+)\-([0-9]+)', line)
|
||||
if sd_re:
|
||||
@@ -145,11 +149,16 @@ def makelist(filename):
|
||||
if todoSrch.group(1) in todos:
|
||||
n.setHeading( todoSrch.group(2) )
|
||||
n.setTodo ( todoSrch.group(1) )
|
||||
|
||||
# extract, set priority from heading, update heading if necessary
|
||||
prtysrch = re.search(r'^\[\#(A|B|C)\] (.*?)$', n.Heading())
|
||||
if prtysrch:
|
||||
n.setPriority(prtysrch.group(1))
|
||||
n.setHeading(prtysrch.group(2))
|
||||
|
||||
# Set SOURCE property to a file+heading based org-mode link to the entry
|
||||
n.properties['SOURCE'] = f'[[file:{filename}::*{n.Heading()}]]'
|
||||
|
||||
return nodelist
|
||||
|
||||
######################
|
||||
|
||||
Reference in New Issue
Block a user