-
Notifications
You must be signed in to change notification settings - Fork 180
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
feat: add support to follow links in markdown format #122
Conversation
local note_name = current_line:sub(open, close) | ||
if note_name:match('^%[.-%]%(.*%)$') then | ||
-- transform markdown link to wiki link | ||
note_name = note_name:gsub("^%[(.-)%]%((.*)%)$", "%2|%1") |
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.
Here I'm changing markdown link to look like wiki link. I think that will be better for compatibility. If someone has custom note_id_func
it will still work nicely with markdown links.
2909a8f
to
f7b4f0b
Compare
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.
Hey @pbogut, this looks good overall, but I just noticed one issue. If you have a markdown link that's actually a URL, :ObsidianFollowLink
will try to create a note based on that URL. That's not ideal. One way we could handle this is to not create notes when the link is markdown style as opposed to Wiki style. Open to other suggestions as well. I just think that URL detection can be tricky.
Isn't that an issue already? I mean, isn't So my questions:
require("obsidian").setup({
url_handle_cmd = "gio open {}",
}) -- Edit: Or even better, add hook instead: require("obsidian").setup({
follow_url_func = function(url) --[[ do what you fancy ]] end,
}) |
f7b4f0b
to
6844ce9
Compare
I suppose you're right. We should probably handle URLs better at some point, but that seems out-of-scope for this PR. |
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.
LGTM! Thanks @pbogut :)
Currently this plugin supports links in wiki format like this:
but markdown links looks bit different
This PR will add support for markdown links to
ObsidianFollowLink
command as well asutils.cursor_on_markdown_link
function.