estruyf / vscode-front-matter

Front Matter is a CMS running straight in Visual Studio Code. Can be used with static site generators like Hugo, Jekyll, Hexo, NextJs, Gatsby, and many more...
https://frontmatter.codes
MIT License
1.85k stars 69 forks source link

Issue: the presence of a colon in a string field causes crashes #792

Open nathanchere opened 3 months ago

nathanchere commented 3 months ago

Describe the bug The presence of a colon in a non-quoted string field causes issues.

  1. The syntax highlighting mistakenly captures text beyond the first colon as part of the key.
  2. The FM activity tab sometimes appears as if no frontmatter schema or content is defined, and sometimes it just outright crashes.

To Reproduce An example of frontmatter which breaks the Frontmatter CMS plugin for vscode:

---
title: Introducing: Star Wars 13
caption: You thought they couldn't ruin Star Wars any further. You were wrong.
---

In this case the syntax highlighting shows "title: Introducing:" as the key instead of identifying "Introducing: " as part of the value

Expected behavior Handle it without crashing. It can be worked around by putting double-quotes around the title (which is done automatically if you enter the colon in the FM activity tab instead of directly in the code editor).

Desktop (please complete the following information):

I've reproduced it on the following:

estruyf commented 3 months ago

Thanks, @nathanchere, for opening the issue. The YAML parser fails to parse the front matter section, and you should see the following error message:

image

Wrapping the title with quotes is the solution, but the CMS does not automatically do it as it would first need a valid YAML object to parse it.