-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(links): insert id link properly #742
Conversation
@@ -181,10 +181,10 @@ function Hyperlinks.get_link_to_headline(headline, path) | |||
id = headline:id_get_or_create() | |||
end | |||
|
|||
if not config.org_id_link_to_org_use_id or not id then | |||
return ('file:%s::*%s'):format(path, title) | |||
if config.org_id_link_to_org_use_id and id then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just swapped the logic for easier readability (no double negation).
if not config.org_id_link_to_org_use_id or not id then | ||
return ('file:%s::*%s'):format(path, title) | ||
if config.org_id_link_to_org_use_id and id then | ||
return ('id:%s::*%s'):format(id, title) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the same url syntax as in file links enables the Url class to parse the parts correctly the existing parsing logic.
@@ -216,9 +216,10 @@ end | |||
function Hyperlinks.insert_link(link_location) | |||
local selected_link = Link:new(link_location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full url including the description a.k.a. headline title is inserted by the user via autocompletion. Link construction parses it and we can get the parts needed parts easily from it to assemble the actual link.
When inserting a stored id link, it is now properly split into link and description. For this to work with the current implementation we need actually to insert id and headline title both into the link input. It get's split and correctly formatted afterwards.
@kristijanhusak I need a reviewer to merge. 😅 |
@chipsenkbeil can you double check if this can cause some issues with your org-roam? I think it shouldn't but I want to be on the safe side. |
@kristijanhusak nothing stands out as an issue to me. @seflue is using the org roam plugin - now a collaborator on the project - so I'm assuming this stems from an issue encountered while using org roam. |
I actually only got aware about the functionality due to my exploration into orgroam. Because I still have a large amount of notes not in orgroam, I use it to connect the "old world" and the "new world" in a filepath-agnostic manner. |
When inserting a stored id link, it is now properly split into link and description. For this to work with the current implementation we need actually to insert id and headline title both into the link input. It get's split and correctly formatted afterwards. Co-authored-by: Sebastian Flügge <seflue@users.noreply.github.com>
When inserting a stored id link, it is now properly split into link and description.
For this to work with the current implementation we need actually to insert id and headline title both into the link input. It get's split and correctly formatted afterwards.