Skip to content
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

zk does not recognize my Wiki link template with a pipe #98

Closed
nogweii opened this issue Nov 3, 2021 · 6 comments · Fixed by #104
Closed

zk does not recognize my Wiki link template with a pipe #98

nogweii opened this issue Nov 3, 2021 · 6 comments · Fixed by #104
Labels
bug Something isn't working

Comments

@nogweii
Copy link

nogweii commented Nov 3, 2021

Here is part of my configuration:

[note]
filename = "{{slug title}}.{{id}}"

[format.markdown]
link-format = "[[{{metadata.id}}|{{title}}]]"

This generates a text link from the LSP something like this:

[[ker6z|Terms of Gardening]]

But it does not get recognized as an actual link to the note:

$ zk list -l Digital\ Garden/terms-of-gardening.ker6z.md
Found 0 note

My intention with the template is to be able to link to a template without worrying what its filename is as well as enabling custom link text in the source document to allow better flow in whatever context it is in.

For me, when "wiki" is listed as a supported link style, I expected nearly-full support of MediaWiki's link syntax but it seems it's much simpler then that. Could this feature be added?

@mickael-menu
Copy link
Member

This should be supported already. I won't have time to test before next week though.

@mickael-menu mickael-menu added the bug Something isn't working label Nov 4, 2021
@nogweii
Copy link
Author

nogweii commented Nov 12, 2021

did some experimenting:

These aren't detected as links at all (no LSP hints at all)

[[ker6z|these terms]]
[[.ker6z|these terms]]
[[ker6z.|foo]]
[[terms-of-gardening | these terms]]

These get detected as a link, but result in 'not found' LSP indicators

[[ker6z | these terms]]
[[these terms|ker6z]]
[[these terms | ker6z]]
[[.ker6z | these terms]]
[[ker6z. | foo]]
[[these terms | Digital Garden/terms-of-gardening.ker6z]]
[[Digital Garden/terms-of-gardening.ker6z | these terms]]
[[these terms | terms-of-gardening]]
[[Digital Garden/terms-of-gardening.ker6z.md | these terms]]
[[these terms | Digital Garden/terms-of-gardening.ker6z.md]]

[Terms of Gardening](terms-of-gardening.ker6z)
[Terms of Gardening](ker6z)

These work as expected

[[Terms of Gardening]]
[[Digital Garden/terms-of-gardening.ker6z]]
[[Digital Garden/terms-of-gardening.ker6z.md]]
[[terms-of-gardening]]
[[.ker6z]]
[[ker6z]]
[[ker6z.]]

[Terms of Gardening](Digital%20Garden/terms-of-gardening.ker6z)
[Terms of Gardening](Digital Garden/terms-of-gardening.ker6z)

nogweii added a commit to nogweii/zk-issues-98 that referenced this issue Nov 12, 2021
@nogweii
Copy link
Author

nogweii commented Nov 12, 2021

I hope this makes it a bit easier, here is a repo to reproduce the error: https://github.com/nogweii/zk-issues-98

@mickael-menu
Copy link
Member

Thanks, I'll take a look this weekend

@mickael-menu
Copy link
Member

@nogweii Thanks, your sample repo was very helpful.

There's actually several issues:

  • The LSP hints are not always reported depending on the type of links. I didn't look into this yet.
  • The first one you reported where --link-to/--linked-by would not work with your wiki links. The issue is that I was matching for a path prefix no matter which type of links was parsed. I fixed this in the following PR to match any portion of a path for wiki links. Let me know if that helps:
    Fix indexing wiki links using partial paths #104

@mickael-menu
Copy link
Member

I fixed the LSP hints/diagnostics in the same PR, there were two issues:

  • Spaces around the pipe were not ignored.
  • I intentionally avoided sending LSP diagnostics if a wiki link had a title (pipe), as I thought it was redundant. But from your examples I realised it was useful so I enabled them.

The only two cases I didn't fix because they are correct are the following from your repo:

[Terms of Gardening](terms-of-gardening.ker6z)
[Terms of Gardening](ker6z)

Markdown links are equivalent to HTML <a> links so it's normal that you can't find these notes as they are located in a sub-folder.

I'll wait for you to test the changes before merging this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants