obsidianmd/obsidian-api

Bug: [METADATA] Broken long line when using fileManager.processFrontMatter

Mara-Li opened this issue · 1 comments

I noticed that long line of text are broken when using :

app.fileManager.processFrontMatter(file, (frontmatter) => {
    frontmatter["key1"] = value;
});

Broken appear as follow:

description: Czena « XVI » Kova, ancienne Sentinelle d'origine russe passée aux
  mains de l'ennemi après avoir perdue toute sa compagnie dans un piège. Test

Instead of :

description: "Czena « XVI » Kova, ancienne Sentinelle d'origine russe passée aux mains de l'ennemi après avoir perdue toute sa compagnie dans un piège."

It appears with ANY string :

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean m : 100 characters
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget : 85
  • Czena « XVI » Kova, ancienne Sentinelle d'origine russe passée aux mains de l'ennemi après avoir perdue toute sa compagnie dans un piège. Test : 142
  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula. 80

Steps to reproduce:
Using the api, trying to do that :

app.fileManager.processFrontMatter(file, (frontmatter) => {
    frontmatter["key1"] = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean m";
});
lishid commented

This is actually intentional as part of the YAML serialization process to have a maximum line width, and automatically fold to next line when it is too long. The newlines are allowed and properly parsed as part of the YAML spec.

I know that this might not be the desirable format for your personal preference, but moving forward, we will be improving the metadata/frontmatter experience such that users won't be looking at the raw source of the YAML. In preparation for that, and to keep things simple, we are standardizing the YAML formatting.