Alias wrapped in quotation marks splitting at comma

Alias wrapped in quotation marks results in two separate aliases when there is a comma.

Steps to reproduce

I have this in my frontmatter:
aliases: "Race for your Life, Charlie Brown"

Expected result:
Race for your Life, Charlie Brown as the alias.

Actual Result:
Race for your Life
Charlie Brown
so 2 aliases.

It works as expected when the current alias, with the quotation marks, is wrapped in square brackets in the frontmatter:
aliases: ["Race for your Life, Charlie Brown"]
gives this alias: Race for your Life, Charlie Brown

Question:

  1. Shouldn’t the quotation marks be enough to create the one alias?
  2. Aren’t the square brackets for multiple aliases rather than a single?

Environment

  • Operating system: Win10
  • Obsidian version: v0.11.13

You could try:

---
aliases:
    - Race for your Life, Charlie Brown
    - Race, Race, Race
---

This produces a sequence of two strings (as intended) and works on my Linux machine, same Obsidian version.

I’d still consider it a bug, since both single- and double-quoted YAML scalars should allow the comma , (and other stuff like the colon :).

Actually, even this should produce one string:

---
aliases: Race for your Life, Charlie Brown
---

You can verify it using the YAML Online Parser.

Examples:

This should produce a sequence of two strings:

---
aliases: [Race for your Life, Charlie Brown]
---

and this a sequence of one string:

---
aliases: ["Race for your Life, Charlie Brown"]
---

and this also a sequence of one string:

---
aliases: ['Race for your Life, Charlie Brown']
---

@Moonbase59 Thanks for reply, and for that link to the YAML parser. Very useful.

re

```
aliases: Race for your Life, Charlie Brown
```

In the comment section of Confusion around yaml alias recommended format @WhiteNoise confirmed that this should produce two aliases (I think). Perhaps that was a mistake?

As far as YAML goes, the above returns a str (correct, to my knowledge), but it seems Obsidian somehow splits the str by commas.

It probably makes it easier for an average user (YAML can be confusing and has some odd rules!) and maybe they thought about tags when programming this, but I still think it’s probably wrong, from a YAML standpoint.

In a YAML str type scalar, the comma has no special meaning, whereas in a (flow) sequence or map it has.

Example:

aliases: this, that

this, that is one str.

aliases: [this, that]

[this, that] is a flow sequence of two comma-separated strs: this and that.

aliases:
  - this
  - that

is also a sequence of two strs: this and that.

Interestingly, in the latter case, Obsidian does it correct: It returns the this and that strings even if they contain commas:

aliases:
  - this
  - that, but it has a comma

will return (correctly) two strs: this and that, but it has a comma!

So yes, I’d consider the current behaviour a bug.

Reference: YAML Ain’t Markup Language (YAML™) Version 1.2

1 Like

thank you, we will look into this.

Ok, I have dug into this. Obsidian introduced a non standard YAML parsing by splitting text at the comma for ease of input.

Obsidian Interprets aliases: a, b and aliases: "a, b" the same way as TWO aliases a and b.

In standard YAML, aliases: a, b and aliases: "a, b" should be interpreted the same was as ONE alias a, b.

The same thing happens with tags.

If you want to adhere more strictly to YAML, I suggest you use the square bracket notation ["a, b"].

If you don’t like this deviation from the standard, open a FR.

2 Likes

@WhiteNoise I’ve entered a feature request here: Yaml alias within quotation marks should be a single alias