Properties: Colon in properties values issue

OBSIDIAN_PROPERTIES_COLON_ISSUE.md (787 Bytes)

Steps to reproduce

  1. Open the attached file with an external editor. Select all text and copy it to the clipboard.
  2. Open Obsidian create a new note and paste the text.
  3. The front matter appears in red because Properties detected two syntax errors: Line 2: “title: PTPL 065: On Clarifying…” and line 3: “ile_title: PTPL 065: On Clarifying…”

Did you follow the troubleshooting guide? [Y]

Expected result

IMHO no errors in the front matter. The two colons are part of value and values can have colons.

Actual result

Obsidian Properties plugin interprets the colons as an issue.

Observe the colons have not been entered using the Properties User Interface. If you use the Properties UI to type colons, all works fine.

So I think may be a parser problem.

Environment

SYSTEM INFO:
Obsidian version: v1.4.3
Installer version: v1.3.7
Operating system: Darwin Kernel Version 23.0.0: Tue Aug 1 03:25:23 PDT 2023; root:xnu-10002.0.242.0.6~31/RELEASE_X86_64 23.0.0
Login status: logged in
Catalyst license: insider
Insider build toggle: on
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

FWIW, the YAML fails in 1.3.7 but parses cleanly if the lines are wrapped in straight quotes:

---
title: "PTPL 065: On Clarifying Your Most Basic Productivity Foundations"
file_title: "PTPL 065: On Clarifying Your Most Basic Productivity Foundations"
published: 2023-08-14T01:01:55.070Z
modified: 
captured: 2023-08-15 08:41:14
author: Ellane W
type: article
locale: en
publisher: Medium
site: 
topics: 
abstract: PLUS a reminder that stepping stones don't need to be made of polished marble
remarks: 
url: https://medium.com/produclivity/ptpl-065-on-clarifying-your-most-basic-productivity-foundations-b09df1baa609
score: 
revised: 
---
# PTPL 065: On Clarifying Your Most Basic Productivity Foundations
([PTPL 065: On Clarifying Your Most Basic Productivity Foundations](https://medium.com/produclivity/ptpl-065-on-clarifying-your-most-basic-productivity-foundations-b09df1baa609))

Thanks for the workaround!

1 Like

Not sure if it should be necessary … we will see, I guess. :wink:

After validating the YAML using 2 online YAML validators, both values for the keys title and file_title appears to be problematic without being quoted so I don’t think this would qualify as a bug as it seems to be an issue with the initial YAML formatting :innocent:

If you copy/paste the string PTPL 065: On Clarifying Your Most Basic Productivity Foundations as it is directly within Properties for the key title (for example), Obsidian automatically surrounds it with double-quotes in the YAML to make it work :blush: .

From YAML documentation, I don’t think it’s the colon (:) in itself that’s effectively the issue but the colon + space (: )

E.g.:

---
t-1: "PTPL 065: On Clarifying Your Most Basic Productivity Foundations"
t-2: PTPL 065:On Clarifying Your Most Basic Productivity Foundations
---

Both are valid YAML keys/values pairs :blush:

1 Like

Yes, if I use he Properties plugin editor to edit the properies, all works, but if the YAML has ben created with an external editor, the parser fails.

Is not a big problem, I know.

Thank you so much for your excellent Work!

Yes, it’s the way YAML handles values. Without quotes, or if you use single quotes it does its best to not interpret the value as a string, and that what breaks it. To force a string you use double quotes. Be careful, if you want the value to be a number, or boolean, do not use double quotes, use single quotes instead, or don’t use any at all.

3 Likes

I think there’s a small misunderstanding :innocent: :

The parser didn’t fail because the YAML were produced by an external editor per se.
It failed, apparently, because the YAML created within the external editor were invalid (as they don’t seem to follow YAML strict formatting rules) :blush: .

In this case, because the string contains a colon directly followed by a space character (: ), the whole sentence would require to be quoted (surrounding it by double-quotes (") ) per YAML formatting rules.

The YAML parser/Properties only works with valid YAML key/value pairs which follows YAML formatting rules…

So, if the YAML it has to handle are invalid, it will just indicate that there’s an issue by “highlighting” the whole thing in red and will wait for you to correct what needs to be corrected…

A small tip to avoid this kind of problem would be to use an online YAML validator before importing adding the file into Obsidian :blush: .
… or maybe take a look at the plugin Linter : a whole section of that plugin is dedicated to YAML and could help you to transform invalid YAML into valid ones (the YAML parser / Properties should then be able to pick it up without troubles) :blush:

I wish there was a really simple guide – with examples – for using YAML in Obsidian.

Something that explains why and when to use

  • single square brackets
  • double square brackets
  • single quotes
  • double quotes
  • double square brackets AND double quotes at the same time
  • etc

:exploding_head:

We just use YAML and there aren’t any flavors of it (unlike markdown). So you pick up any YAML guide and use any YAML linter. That’s not gonna be as easy as markdown and that’s why the need for UI.

Regarding this bug report. It’s not a bug, you manually entered incorrectly formatted YAML. You do need quotation marks in this case.

1 Like

In JS/TS single squared brackets ([]) are arrays/lists and same goes for YAML: so single squared brackets ([]) can be used to indicate a list of values :blush:

E.g.:

---
list-1:
  - item 1
  - item 2
  - item 3
list-2: [item 1, item 2, item 3]
---

Lists - Properties

Both format of list are valid in terms of YAML but Obsidian, at the moment, forces the use of the list-1 format for lists :blush:

Those are for wikilinks :blush: .
But, because single squared brackets can be used to indicate a list of values, they need to be explicitly inserted as strings (with the whole link surrounded by double/single-quotes) to avoid confusion :blush: (as it could be read as a list of lists of values without being quoted)

---
link: "[[Untitled]]"
link-list:
  - "[[Untitled]]"
  - "[[Untitled 1]]"
---

Links - Properties

As for the single quotes vs. double quotes, I didn’t really looked at this at the moment :sweat_smile:

Many thanks. I am slow to learn. :face_holding_back_tears:

1 Like

My pleasure :blush: !

1 Like

But an array of tags doesn’t need square brackets? And numbers need double quotes, expect if the value is a single number?

When queried in Dataview, lots of the frontmatter keys and values below don’t register at all and yet they parse in the file in reading mode.

I know, I need to learn. :face_with_head_bandage:

---
tags: cat, sat, mat
key: [value, values, valued]
lock: one, two, three
number: ["5", "7", "37", "36,756"]
numbers: [5, 7, 37, 36,756]
numbered:
  - 5
  - 7
  - 37
  - 36,756
numeral: 1
---
 
```dataview
LIST this
WHERE file.name = this.file.name
```

And all of the above passes a YAML lint online:

I sadly haven’t been able to play with Dataview (for a while now :sweat: ) so I’m not sure how Dataview works with Properties :sweat_smile:

We’re in the same boat :sweat_smile: :wink: … This is why, so far, I’ve been keeping almost all of my YAML as simple text values :innocent:

Edit: Just to say that Dataview is not yet Properties ready as stated in this GH comment :blush:

1 Like

Thanks.

I’ve disabled automatic updates … going to stay on 1.3.7 until I really understand Properties and the impact it will have on thousands of notes and queries.

1 Like

Ok. But if I use the Obsidian Properties editor and I write a value with a colon, it works. And the parser says OK. And it says OK because the Obsidian Properties Editor is smart: detects the colon and adds quotes before and after the text automatically. So is really a Good editor.

Now I use quotes when I need a colon,

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.