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

[FEATURE REQUEST] Optioin to prepend/appened custom string to link display text #26

Closed
greetclammy opened this issue Jan 4, 2025 · 7 comments

Comments

@greetclammy
Copy link

greetclammy commented Jan 4, 2025

Edit: see discussion below for an update to this request.


Is your feature request related to a problem? Please describe.
When creating a link with an alias in Obsidian that matches the link target (e.g. [[target|target]]), if the target note gets renamed, the alias also gets renamed automatically since version 1.2.1. This breaks the original text flow where the link appears, as the displayed text changes unexpectedly. This is a long-standing issue, as discussed in this feature request.

Describe the solution you'd like
Add an option to plugin settings to automatically insert an invisible whitespace character in the link alias text when creating a link with identical target and alias via one of the plugin's commands. This would make them technically non-identical while appearing visually identical, preventing the link alias from being renamed when the target note is renamed.

Describe alternatives you've considered

  1. Manually adding a visible character (like ~) to differentiate the alias.
  2. Using different capitalization for alias vs target.
  3. Using the Smart Rename plugin to handle renames manually.

Additional context

  1. This would solve the issue introduced in Obsidian 1.2.1 without requiring manual intervention or visible markers. The invisible whitespace character would be completely transparent to reading and writing while maintaining the desired text appearance when files are renamed.
  2. This idea was inspired by this PR for Auto Link Title: Add option for better paste IDs using invisible characters zolrath/obsidian-auto-link-title#125
@pvojtechovsky
Copy link
Owner

Hi @greetclammy

if the target note gets renamed, the alias also gets renamed automatically since version 1.2.1.

Is this behavior still existing? I cannot reproduce that.

The link [[target|target]] changes to [[targetx|target]] after I rename note target to targetx, what seems like feature/bug you describe doesn't exist ... at least I cannot reproduce it.

How to do you reproduce it? What are exact steps? May be I rename note by different way than you?

@greetclammy
Copy link
Author

Weird! Here:

Screen.Recording.2025-01-06.at.18.55.45.mov
SYSTEM INFO:
	Obsidian version: v1.7.7
	Installer version: v1.7.7
	Operating system: Darwin Kernel Version 20.6.0: Thu Jul  6 22:12:47 PDT 2023; root:xnu-7195.141.49.702.12~1/RELEASE_X86_64 20.6.0
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: dark
	Community theme: none
	Snippets enabled: 0
	Restricted mode: on

RECOMMENDATIONS:
	none

@pvojtechovsky
Copy link
Owner

Thanks, I see the difference now. When link is created by this plugin then it always creates an alias property

---
aliases=target
---

In such case the links like [[target|target]], which points to the file with the aliases=target, are not renamed when file is renamed. In such case obsidian doesn't rename alias and doesn't rename link display text, so it stays as [[target2|target]].

So you just need to create aliases for all your links and then obsidian will not rename them.

So I would say that this Feature request is no more relevant.

May be you need another feature request like:
A) create alias for all links with display text
B) create document with alias when new document is made immediately by pressing ALT+ENTER after Create link with alias command is used.

Note: if you have world like "collagen" and doesn't have target note yet for it and when you select collagen and run command Create link with alias, then you can actually move cursor out of the newly created link and after short time the plugin understands that your are done with your link and makes Note file for that link ... correctly with the alias.
But if you press ALT+ENTER then obsidian creates the file and plugin doesn't create alias in such case. I might improve that if that is your use case.

@pvojtechovsky
Copy link
Owner

I solved the problem with Alt+Enter in brand new link (see #23) and release 1.0.9.
@greetclammy I guess we can close this feature request.

@greetclammy
Copy link
Author

greetclammy commented Jan 9, 2025

I solved the problem with Alt+Enter in brand new link (see #23) and release 1.0.9. @greetclammy I guess we can close this feature request.

Thank you for the detailed response and a swift update to the plugin!

Curious. It's almost like the plugin was made as a workaround for the issue that was introduced in Obsidian ver. 1.2.1.

While the workaround you outlined is a good one, it doesn't cover my use case because:

  1. Unresolved links are still affected by the problem outlined in the OP.
  2. I wouldn't want to turn unresolved links into existing notes just to insert an alias in their frontmatter. This would clutter up my vault with empty notes. Also, the distinction between resolved and unresolved links would be lost (I'm mostly referring to how unresolved links appear as dim compared to resolved links.)
  3. Furthermore, I wouldn't want to clutter up the frontmatter of my notes with various aliases (which can be quite long) as a mere workaround to this problem.

I'm now prepending ~ to link display text for all links to prevent any chance of the auto-rename added in ver. 1.2.1 from happening. It'd be wonderful if Link with alias allowed me to automate this action. So I'm now requesting an option to prepend or append any custom string to the link display text. If introducing such an option, perhaps the setting description should explain the reasoning for it because not a lot of users know about the issue added in ver. 1.2.1.

I attempted to create a Templater script that would achieve this but, unfortunately, it cannot be run in cards in Canvas, which is a major downside... (Made a FR for this). Which is why I'd like to keep this issue open. If you're not sold, perhaps we should wait and see if there's any more interest in this request.

@greetclammy greetclammy changed the title [FEATURE REQUEST] Auto add invisible whitespace character in link display text to differentiate it from link target [FEATURE REQUEST] Optioin to prepend/appened custom string to link display text Jan 9, 2025
@pvojtechovsky
Copy link
Owner

This plugin is mainly for adding aliases.

I was thinking about plugin extension which would automatically add alias for every new document made from the unresolved link. That would be solution too.

I wouldn't want to clutter up the frontmatter of my notes with various aliases

So this is no solution for you.

If your use case is different and aliases are not the think you need, then you need a completely new plugin.
I also do not want to make setting of this plugin more complicated just for this minor use case. (I guess there are not many users who will use it with combination with this plugin)

So actually I don't want to introduce this feature request. And I would probably even not accept pull request for that.

@greetclammy
Copy link
Author

Understood. I solved this issue with Linter. I explained it here, if anyone bumps into this issue in the future: https://forum.obsidian.md/t/add-option-to-always-preserve-original-link-text-as-display-text-alias-when-the-target-note-is-renamed-dont-change-original-text-when-updating-links/6521/32

@greetclammy greetclammy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2025
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

No branches or pull requests

2 participants