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

Support slug-only wikilinks and improve link preview pop-ups #1259

Closed
redactedscribe opened this issue Jul 15, 2023 · 1 comment · Fixed by #1289
Closed

Support slug-only wikilinks and improve link preview pop-ups #1259

redactedscribe opened this issue Jul 15, 2023 · 1 comment · Fixed by #1289

Comments

@redactedscribe
Copy link

redactedscribe commented Jul 15, 2023

Is your feature request related to a problem? Please describe.

Issue #536 implemented slugs (headers) in wikilinks that include a link to another document, but not for those which are simply a [[#link-to-a-slug]] within the same document.

  • [Building using Docker](#building-using-docker) works as a link both in the editor and the Markdown preview but does not show a preview pop-up when hovering over the slug in the editor (only "Follow link").
  • [[#Building using Docker]] shows a preview pop-up and also works as a link in the editor but not as a link in the Markdown preview ("Link to non-existing resource").
    • If the document hasn't been saved and the position of the header has changed, clicking the link will jump to the position where the header was, not where it currently is.
    • Typing # within [[]] suggests and inserts headers which are as written in the Markdown document (i.e. not slugified). It would be nice if which style gets suggested would be an option that Foam supports.
  • [[#building-using-docker]] (slugified) links to the top of the document, not to the heading itself. If slugified headers in wikilinks aren't meant to be supported, then the link shouldn't work at all. Hovering over the slug in the editor shows a preview pop-up but again of the top of the file. The link does not work in the Markdown preview.
    • [[Docker doc#building-using-docker]] works as a link in the Markdown preview, but the link and preview pop-up doesn't in the editor ("Cannot find section "building-using-docker" in document ...").
  • [Building using Docker](Docker%20doc.md#building-using-docker) doesn't show a preview pop-up with or without a slug, but always links correctly, in both the editor and Markdown preview.

Describe the solution you'd like

Ideally we would be able to write any of these wikilink variations:

  • [[#Building using docker]]
  • [[#building-using-docker]]
  • [[#building-using-docker|Building using Docker]]
  • [[<basename>#Building using docker]]
  • [[<basename>#building-using-docker|Building using Docker]]

...and have both functional links in the editor and the Markdown preview, and for preview pop-ups to display accurately for them in the editor.

I guess the question I have is why do we suggest headers as-written instead of as slugs in the first place? Maybe because they look nicer? I'd argue that it doesn't hold up if you've chosen to hyphenate your filenames; hyphen-for-spaces throughout would perhaps look nicer in that case. Slugs would be easier to convert into normal Markdown links at a later date, if necessary.

Describe alternatives you've considered

Currently, the only slugified link which works is the normal Markdown link format [Building using Docker](#building-using-docker), however as noted above, it doesn't show a preview pop-up like the other link formats.

I currently have a few of these [[#slug|Slug]] wikilinks and hope they will become functional in the future.

Thanks.

Edit: I had written some false information and it has now been corrected and clarified.

Foam 0.25.0

Screenshots or Videos

No response

@riccardoferretti
Copy link
Collaborator

Foam doesn't sluggify file names nor section names.
To link to my file.md the wikilink is [[my file]].
To link to ## My header the wikilink is [[#My header]].

The link to the section currently works in the editor but doesn't in the preview, we can add support for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants