ttrpg-convert-cli icon indicating copy to clipboard operation
ttrpg-convert-cli copied to clipboard

✨ Wrap aliases containing a colon (:) in "double quotes"

Open MasssiveJuice08 opened this issue 3 months ago • 7 comments

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: Image

Image

MasssiveJuice08 avatar Oct 12 '25 07:10 MasssiveJuice08

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.

jboehm77 avatar Nov 05 '25 03:11 jboehm77

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.. ?

ebullient avatar Nov 06 '25 14:11 ebullient

better plan.. I'll add resource.aliases, which will always emit a list of quoted items..

ebullient avatar Nov 06 '25 14:11 ebullient

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"

jboehm77 avatar Nov 06 '25 14:11 jboehm77

yes. that would be the goal.

ebullient avatar Nov 06 '25 15:11 ebullient

Fixed by dd30d55479d41fb7df3f304d879375c8f590db68?

jboehm77 avatar Nov 12 '25 03:11 jboehm77

Once people update their templates, yes. Also need to release it.

ebullient avatar Nov 12 '25 20:11 ebullient