Issue: FrontMatter changes front matter line length #408

Closed
opened 2026-10-05 02:45:42 +02:00 by adam · 6 comments
Owner

Describe the bug
It appears the frontmatter functionality that updates the dates on save is also formatting the frontmatter. I have a line with the length of >80, but below 120 and after each save that line is ripped onto two lines. Now, while this is done properly (yaml, second line of a parameter is indented by 2 extra spaces) it might/will break other parsers that want to go over frontmatter. It would be nice to be able to either configure it to a certain line length or be able to disable it.

I am not 100% sure that it is FrontMatter doing this, but I disabled all Markdown extensions, eslint and prettier and it still cut the line in two, after disabling frontmatter this stopped.

sample:

---
date: 2023-02-26T21:27:05+07:00
publishDate: 2023-02-26T21:27:05+07:00
lastmod: 2023-02-27T17:20:47+07:00
resources:
  - src: header.jpg
    title: Photo by [Todd Quackenbush](https://unsplash.com/@toddquackenbush) via [Unsplash](https://unsplash.com/)
---

ends up as:

---
date: 2023-02-26T21:27:05+07:00
publishDate: 2023-02-26T21:27:05+07:00
lastmod: 2023-03-01T18:50:15+07:00

resources:
  - src: header.jpg
    title: Photo by [Todd Quackenbush](https://unsplash.com/@toddquackenbush) via
      [Unsplash](https://unsplash.com/)
---
**Describe the bug** It appears the frontmatter functionality that updates the dates on save is also formatting the frontmatter. I have a line with the length of >80, but below 120 and after each save that line is ripped onto two lines. Now, while this is done properly (yaml, second line of a parameter is indented by 2 extra spaces) it might/will break other parsers that want to go over frontmatter. It would be nice to be able to either configure it to a certain line length or be able to disable it. I am not 100% sure that it is FrontMatter doing this, but I disabled all Markdown extensions, eslint and prettier and it still cut the line in two, after disabling frontmatter this stopped. sample: ```markdown --- date: 2023-02-26T21:27:05+07:00 publishDate: 2023-02-26T21:27:05+07:00 lastmod: 2023-02-27T17:20:47+07:00 resources: - src: header.jpg title: Photo by [Todd Quackenbush](https://unsplash.com/@toddquackenbush) via [Unsplash](https://unsplash.com/) --- ``` ends up as: ```markdown --- date: 2023-02-26T21:27:05+07:00 publishDate: 2023-02-26T21:27:05+07:00 lastmod: 2023-03-01T18:50:15+07:00 resources: - src: header.jpg title: Photo by [Todd Quackenbush](https://unsplash.com/@toddquackenbush) via [Unsplash](https://unsplash.com/) --- ``` <!-- github-sync-id:1604821514 -->
adam closed this issue 2026-10-05 02:45:42 +02:00
Author
Owner

Thanks @davidsneighbour, found the issue. It seems to be caused by the YAML parser. I did an update to it, and now it should not break your lines anymore.

Let me know if this fixed it for you in the beta version.

Thanks @davidsneighbour, found the issue. It seems to be caused by the YAML parser. I did an update to it, and now it should not break your lines anymore. Let me know if this fixed it for you in the beta version. <!-- github-comment-id:1451671849 -->
Author
Owner

Yes, that fixes it. Thank you :)

Yes, that fixes it. Thank you :) <!-- github-comment-id:1451865966 -->
Author
Owner

I hate to be of bother ;) But now it removes all empty lines that I use just to keep an overview over the front matter. That is ok and valid and I think the initial issue is worse than that, but maybe it's easy to save empty lines the front matter?

(Or it's maybe another issue? Still using the Beta Version)

I hate to be of bother ;) But now it removes all empty lines that I use just to keep an overview over the front matter. That is ok and valid and I think the initial issue is worse than that, but maybe it's easy to save empty lines the front matter? (Or it's maybe another issue? Still using the Beta Version) <!-- github-comment-id:1455075650 -->
Author
Owner

No worries, we need to get this right. The issue is in one of the YAML parsers, one has a setting to set a line length, but seems to remove other things, and the other one keeps things in place but doesn't have a line length setting.

No worries, we need to get this right. The issue is in one of the YAML parsers, one has a setting to set a line length, but seems to remove other things, and the other one keeps things in place but doesn't have a line length setting. <!-- github-comment-id:1455773456 -->
Author
Owner

Just saw that with the latest version of the YAML parser, there is a line width option. I just updated the dependency and made the change. This gets the old experience back + the fix for the line width.

Just saw that with the latest version of the YAML parser, there is a line width option. I just updated the dependency and made the change. This gets the old experience back + the fix for the line width. <!-- github-comment-id:1455806980 -->
Author
Owner

It appears this did not make it into 8.4.0 or got somehow broken again. Saving markdown files removes empty lines currently in v8.4.0. The line length is working.

edit: not sure if a closed issue arrives on your notifications, so I'll ping you @estruyf ;)

It appears this did not make it into 8.4.0 or got somehow broken again. Saving markdown files removes empty lines currently in v8.4.0. The line length is working. edit: not sure if a closed issue arrives on your notifications, so I'll ping you @estruyf ;) <!-- github-comment-id:1503259159 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#408