How to find broken YAML?

Is there a way to promptly search one’s vault for broken YAML, either native or through a plugin?

Since I find my notes through dataview, broken YAML properties means lost note, and I have update their metadata through a method that occasionnally breaks the YAML without me noticing. I know they get highlighted in red in the file itself when something is wrong, but I can’t afford to click through the 4235 (and growing) files in my homemade database to check which are broken or not.

Sorry if the question’s been asked before, couldn’t find any topic on this.

Thanks in advance!

yq is a greate yaml tool

From what I see I’d have to copy paste the content of each individual file somewhere (which would still be very time consuming)?

It seems to offer a lot of other options so I’m struggling to understand how to apply it for the single use I’d need it for in the various documentation I’m finding.

How did this corruption happen, in first place?

try plugins like global search and replace or Linter to correct your yaml headers

I update my files using macros to copy-paste them from the source of info (I wish i’d found a better solution but so far I haven’t)

The macros sometimes break for a keystroke and break one single file among hundreds, which I don’t necessarily notice.

The end result would be something like this;

category: Manga
Serie: "[[Doraemon]]"2
NSerie: 25
NumBorrowed: 2016-02-09

When it should be this:

category: Manga
Serie: “[[Doraemon]]”
NSerie: 2
NumBorrowed: 25
AcquisitionDate: 2016-02-09

The YAML will highlight in red within the file, because suddenly there’s a number outside the quotation and the recently implemented properties won’t work. Alternatively, the properties will sometimes indicate that the field is not conforming to the type set for it (for example, a date instead of a number), but it only signals it if you’re inside the file.

I don’t think global search and replace or Linter can tell me when this happens, but maybe I’ve missed a way to use them?

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