Slugification of wikilinks #1033
Replies: 24 comments 9 replies
-
Same issue faced by me. Is the issue that we can't have spaces while creating a new note? |
Beta Was this translation helpful? Give feedback.
-
This is happening because in 0.10.0 we are less lenient towards slugified links.
Basically the two have to match. The reason why they appear to match in the graph is that we show the note title ( Can you confirm the same is true for the you @iamtherealgd ? |
Beta Was this translation helpful? Give feedback.
-
The comment above about the naming of the wikilink and the file solves my issue. This is issue is resolved at my end by fixing the names of the wikilink references. Before closing this issue documentation shall be made clear to explain this fact that the heading is shown in Graph view whereas the reference is to a file name hence the wikilink reference should match the file name not the title of the page. |
Beta Was this translation helpful? Give feedback.
-
I think what I was doing wrong was the link was in capital case like [[Maintainable]] and its file was maintainable.md. But I created the maintainable.md file by the shortcut So Foam creates new files in lowercase irrespective of the case how it's mentioned in some other note, is there a way to change this? |
Beta Was this translation helpful? Give feedback.
-
that's a really good thought @iamtherealgd - I had not thought of that.
my take is that we can be lenient about letter case, even if the implicit tradeoff is that we don't support
currently the note creation from the link is managed by Markdown Notes, but we'll soon bring this in house for better compatibility |
Beta Was this translation helpful? Give feedback.
-
I prefer my filenames to not have space, and at the same time I prefer that the text in wikilink to not have hyphen. So the first option of having filenames with space is a big no for me. I think [[unhyphenated wiki links]] look much nicer than [[hyphenated-wiki-links]] in general and more so especially when the slugified filename is long. @riccardoferretti reading your comments above I get an impression that this behaviour is undesirable. I was wondering what would be the argument against having [[wiki link with space]] link to |
Beta Was this translation helpful? Give feedback.
-
This is exactly the issue I'm facing. |
Beta Was this translation helpful? Give feedback.
-
Today I created a wikilink [[active-recall]] exactly as expected by Foam and created the file by Cmd+Click making a file active-recall.md, the Foam Graph is still showing phantom node 'Active Recall' and connected node as 'active-recall' which is gray |
Beta Was this translation helpful? Give feedback.
-
Adding a level of indirection, a slugification function, between the text of the wikilink and the corresponding file name creates complexity for other features and use cases. For example we are adding refactoring support, where wikilinks will be updated when a file is renamed. Also, slugification gets in the way of other use cases, e.g. you wouldn't be able to easily support spaces in file names: if you have two files, An additional level of complexity is due to several slugification functions incompatible with each other (we have already dealt with this problem in Foam for markdown-notes). Slugification is also unfriendly towards non-latin alphabets. Finally, there are workarounds that could be implemented to satisfy the use case without breaking the core contract, which admittedly require features that are in the works, but that are actually coming soon:
|
Beta Was this translation helpful? Give feedback.
-
This seems like a different issue, can you please create a reproducible scenario and file an issue for it? |
Beta Was this translation helpful? Give feedback.
-
@iamtherealgd can you also please create another issue for your problem? I think that's something we need to properly support and would like to untangle it from this issue |
Beta Was this translation helpful? Give feedback.
-
Tangentially, having had similar experiences to many of yall's, I have found joy in |
Beta Was this translation helpful? Give feedback.
-
@riccardoferretti It sounds like there are a lot of assumptions on what is good for how people should name their files here. I wonder how often the combination of cases mentioned here happens. Given there are people who would like to just have Foam work with their files of which spaces exist in file names, would it not be more preferable to leave an option for the user to set whether slugification should be turned on or not in Foam core, instead of putting everyone to a one-size-fit-all solution? |
Beta Was this translation helpful? Give feedback.
-
We could make it customizable, but this would add complexity and maintenance cost. I am not against your suggestion, I feel though that there are other tasks with higher priority, and that this change has the potential of making the development of other features more complex. For those reasons we are not considering this work ATM. If there were a lot of requests for it I am open to reconsideration - but right now the cost/complexity of adding support for it is not worth the candle IMO. |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
Thanks for your comment @njnygaard, it doesn't change my thoughts above but it is a good data point. We have had a few conversations here and in Discord about the slugification of wikilinks and we might end up supporting it again in the future, it's just not a big priority now |
Beta Was this translation helpful? Give feedback.
-
Is it intended that Foam works best with slugified lower case, but Foam: Create New Note calls for a Title Case Name for the note, which is explicitly then not lower-cased and slugified? I've been doing a lot of "Foam: Create New Note" and then having to rename the file. |
Beta Was this translation helpful? Give feedback.
-
I am not sure what you mean by "works best". it supports it, it's not tailored for it. @movermeyer, what do you think of that? I believe it is backwards compatible and doesn't add regressions. |
Beta Was this translation helpful? Give feedback.
-
In my installation, if I create a note/link like [[Three Word Link]], GitHub has problems rendering it. Maybe the issue is that there's a mix of support from rendering engines for links like [[three-word-link|Three Word Link]] to use slugified names while making the link names look nice when rendered by a git engine. |
Beta Was this translation helpful? Give feedback.
-
I sadly don't have the spoons to reproduce with a small example, but I think I'm experiencing the same thing as @vJourneyman mentioned. I have "imported" a few markdown files (that originally came from OneNote, using an export script) and these files have filenames that contain multiple dashes, dots, apastrophes, and I understand somewhat when they make problems. But even removing them does not seem to help - there still is every node twice in the Foam Graph except for a few. However, it seems that renaming the file to use lowercase-only naming fixes this. At least after deleting and recreating the wikilink. Notably, the "duplicates appearing in the Foam Graph" problem does not happen on my ubuntu laptop with the files that cause problems synced via syncthing. So it miiight have to do with Windows/NTFS? Steps for Repairing a Node that appears twice in the Graph
I'm automating the renaming for all files (not recursive) in the folder using # in cmd
for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f") (explanation here) and to change the wikilinks to lowercase in the file: # in cygwin
sed 's/\(\[\[[a-zA-Z-]*\]\]\)/\L\1/g' my-linking-file.md but that did not seem to do the whole trick. While I first thought it fixed everything, after reopening vscode the duplicates are back. But now it seems that the duplicates are using as path Now I closed vscode, removed all the wikilinks in Notepad++, reopened vscode, and the Foam graph looks beautiful and correct again - except for the fact that it shows wikilinks that are not there. As soon as I touch and save the file in vscode again, it regenerates the references and the dupe appears in the graph. After removing the link references once again, but this time on the linux computer, and saving it in vscode again (on linux), then waiting for the sync and reopening vscode on the windows machine seems to have repaired the graph - it shows no dupes and no imaginary connections. However, just hitting ctrl+s in the file on windows is enough to recreate the dupes in the graph view. |
Beta Was this translation helpful? Give feedback.
-
I would appreciate support for a |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Here is a quick update on this:
|
Beta Was this translation helpful? Give feedback.
-
After a conversation here I will post also in this discussion as people in it might find it useful. Let's go back to the reasons why I decided to make the switch:
Beside all of those reasons, from a design POV I simply don't believe that slugs are a good foundation, and that's why I chose to get rid of them. I might be wrong, by all means, I have just not been persuaded by the arguments yet. At the same time we had some features in the works that would have softened the blow for people that really like to use slugified filenames:
With these building blocks we currently have we are getting very close to have an almost seamless support for slugification (if you are happy with all your links looking like And maybe in the future we'll have link definitions (my last point above) as a great way to support "non-aliased" slugs links in Foam, but that is not a priority in my opinion at this point. I don't expect everyone to agree with the design choice, and I do appreciate the feedback (when done constructively), slug vs non-slug has been an ongoing topic, and I do want to build a solution that in the end works for the majority of users. |
Beta Was this translation helpful? Give feedback.
-
Summary
Foam Graph shows two entries for same note. One entry is shown orphan which is active. The actual link is shown as inactive.
Steps to reproduce
Additional information
I have attached a demo project with only the actions I have taken and the foam graph has that issue
The project started from Foam Template and I have added some extension suggestions which I am already using
foam-graph-test.zip
Beta Was this translation helpful? Give feedback.
All reactions