✨ Wrap aliases containing a colon (:) in "double quotes"
Describe the solution you'd like
Some notes generate an alias which contains a colon, e.g.,
---
aliases:
- Chapter 1: The Basics
---
However, this causes Obsidian to give an error "Type mismatch, expected Aliases". Is it possible for the CLI to wrap these in single or double quotes like below?
---
aliases:
- "Chapter 1: The Basics"
---
Describe alternatives you've considered
The following regex works to find aliases containing a colon, and wrap these in double quotes (tested in GrepWin with 'Dot matches newline' enabled):
- regex find:
(aliases:\r?\n)(- ([^:\r\n]+: [^\r\n]+)) - regex replace:
\1- "\3"
Manually fixing the aliases works too, but is tedious with large vaults.
Additional context
I believe this behaviour was introduced with f1c1159. See #682
Example in Obsidian of the type mismatch:
Fyi, I noticed a potential solution to this mentioned in #804 that can be used in templates. Formatting the header in a template as follows seems to generally avoid Obsidian errors:
---
aliases:
- "{resource.name.replace('"', '\"')}"
---
This should allow proper handling of aliases with : colons, " double quotes, and ' single quotes without errors.
Given that.. I don't know how to safely fix what the template itself does.
If the template adds the quotes, then the above is broken.. though I suppose it is easy enough to undo again.. ?
better plan.. I'll add resource.aliases, which will always emit a list of quoted items..
Will resource.aliases in this case innately include escaped characters \" for aliases with internal quotes? So for example Rosavalda "Rosa" Durst would need to have its aliases as:
aliases:
- "Rosavalda \"Rosa\" Durst"
yes. that would be the goal.
Fixed by dd30d55479d41fb7df3f304d879375c8f590db68?
Once people update their templates, yes. Also need to release it.