Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOML frontmatter extraction should look between +++ instead of --- #3094

Closed
jpcaruana opened this issue Jan 7, 2023 · 6 comments · Fixed by #3254
Closed

TOML frontmatter extraction should look between +++ instead of --- #3094

jpcaruana opened this issue Jan 7, 2023 · 6 comments · Fixed by #3254
Labels
bug Something isn't working needs triage

Comments

@jpcaruana
Copy link

Describe the bug

Steps to Reproduce

extract TOML frontmatter from a hugo/zola blog post:

+++
title = "Title"
+++
Content

using https://deno.land/std@0.171.0/encoding/front_matter/toml.ts doen't extract the frontmatter at all as it looks between ---instead of +++

Expected behavior

Extract the TOML frontmatter contained within +++

Environment

  • OS: MacOS 12.4
  • deno version: 1.29.2 / v8 10.9.194.5 / typescript 4.9.4
  • std version:0.170.0

see https://github.com/denoland/deno_std/blob/main/encoding/front_matter/mod.ts#L176 where separator for TOML is --- instead of +++ (as described in https://gohugo.io/content-management/front-matter/#front-matter-formats)

@kt3k
Copy link
Member

kt3k commented Jan 11, 2023

Is this convention common across tools? Or specific to Hugo?

@lino-levan
Copy link
Contributor

It's definitely not in the spec (ref: toml-lang/toml#511). I think that this is application-specific, but I honestly don't see a lot of tools that use toml front matter in general. I would be okay with changing it just because of Hugo because Hugo is the only tool I know of that even offers it as an option.

Alternatively, maybe this is an option we can provide instead (though that looks to be difficult given there is a lot of regex involved)?

As an aside: for a language that claims to be designed around simplicity, parsing it sure seems to be a nightmare.

@jpcaruana
Copy link
Author

Hi, both zola and hugo use +++as the TOML delimiter.

@lino-levan
Copy link
Contributor

I guess the better question is: are there tools that DON'T user +++ as the TOML delimiter? If so, then this is a breaking change for (in my opinion), limited gain.

Why don't we parse --- ---toml AND +++ instead of just picking between --- and +++? I feel like that would be the best for everyone in this situation.

@kt3k
Copy link
Member

kt3k commented Jan 23, 2023

I researched a bit about toml front matter support across tools:

+++

(in addition to zola and hugo)

---toml

(further inputs are very welcome)


It looks reasonable to add +++ support to toml front matter, but let's keep ---toml as it looks also common across tools. I agree with the suggestion by @lino-levan

@lino-levan
Copy link
Contributor

Good to know I'm not completely off base 😄. Cool to see a more complete analysis of tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
3 participants