chrisgrieser / shimmering-obsidian

Alfred Workflow with dozens of features for controlling your Obsidian vault.
https://alfred.app/workflows/chrisgrieser/shimmering-obsidian/
MIT License
817 stars 40 forks source link

Update WikiLink syntax to unencoded and fix heading bug #177

Closed johannrichard closed 2 months ago

johannrichard commented 2 months ago

Markdown Link title and WikiLink without URI encoding

Markdown Links (which include the obsidian:// URL scheme) keep the URI encoding for the file path while also using the unencoded version for the Display. WikiLinks do not need to be URI encoded at all.

This change will ensure that WikiLinks are thus created in the unencoded form and that this will also be used for the displayed text in Markdown Links. I acknowledge there might have been a design decision to use URI encoding both for the displayed title as well as the file in the Obsidian URI – if this is the case happy to discuss and understand.

The linkt to a file named My Fabulous Obsidian File.md in Obsidian is currently rendered as follows (Markdown link and WikiLink, respectively):

[My%20Fabulous%20Obsidian%20File](obsidian://advanced-uri?vault=VAULT&file=My%20Fabulous%20Obsidian%20File.md)
[[My%20Fabulous%20Obsidian%20File]]

Whereas with the change, it will be

[My Fabulous Obsidian File](obsidian://advanced-uri?vault=VAULT&file=My%20Fabulous%20Obsidian%20File.md)
[[My Fabulous Obsidian File]]

Fix for a "heading" bug

I always get the #heading version, even if no heading is selected in Alfred. When debugging the script, I saw it processed a string value of undefined on my Systems. This contains an attempt to fix this by testing for "heading" and its value instead of testing for an empty / non empty variable. This was with newer versions of macOS Sonoma, and the newest Alfred Version.

chrisgrieser commented 2 months ago

This change will ensure that WikiLinks are thus created in the unencoded form and that this will also be used for the displayed text in Markdown Links. I acknowledge there might have been a design decision to use URI encoding both for the displayed title as well as the file in the Obsidian URI

Actually, it wasn't. So appreciate the fix!