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 is rendered differently in code-toggle with v0.87.0 #1505

Closed
jmooring opened this issue Aug 3, 2021 · 5 comments
Closed

TOML is rendered differently in code-toggle with v0.87.0 #1505

jmooring opened this issue Aug 3, 2021 · 5 comments

Comments

@jmooring
Copy link
Member

jmooring commented Aug 3, 2021

Example:
https://gohugo.io/hugo-modules/configuration/#module-config-mounts

v0.86.1

v0.86.1

v0.87.0

v0.87.0

I suspect this is due to the changes in the TOML library.

@jmooring
Copy link
Member Author

jmooring commented Aug 3, 2021

IMO this is not a bug, it is just different than it was before. The transform.Remarshal function now encapsulates strings with single quotation marks by default, using double quotation marks only when needed.

This:

{{ $map := dict "test" (
  slice
    (dict "a" "foo\n" "b" 1)
    (dict "a" "bar" "b" 2)
  )
}}
<pre>{{ transform.Remarshal "toml" $map | safeHTML }}</pre>

Renders as:

[[test]]
a = "foo\n"
b = 1
[[test]]
a = 'bar'
b = 2

Whether or not the lack of indentation and blank lines is a good thing is debatable, but there is nothing inherently wrong with the current behavior.

@bep
Copy link
Member

bep commented Aug 3, 2021

I will add indentation in gohugoio/hugo#8850 -- the other remarks are improvements, in my head (or: they are in line with the TOML 1.0 spec where only 2 quotes are mentioned: single and triple; go-toml does support double quotes as well, which is good, at many sites would have blown up if now...).

@jmooring
Copy link
Member Author

jmooring commented Aug 4, 2021

I am primarily concerned about possible confusion and inconsistent documentation:

  • "Why do some examples use single quotes, while others use double quotes?"
  • "When I convert YAML/JSON to TOML using online tools, the result has double quotes, not single quotes. Why?"
  • "Should I be using single quotes with YAML and JSON too?"
  • "All of the examples on Discourse have double quotes, but..."
  • "Should I be using single quotes in my frontmatter too?"
  • "Do I need to convert all my existing TOML from double to single quotes?"

But I'm paranoid.

@jmooring jmooring closed this as completed Aug 4, 2021
@bep
Copy link
Member

bep commented Aug 4, 2021

@jmooring I know what you're talking about, but all of this is a balance game: We replaced a buggy, non-spec-compliant and unmaintained TOML library with a faster, TOML 1.0-compliant and well maintained library. On the net side of everything, this is a win.

@jmooring
Copy link
Member Author

jmooring commented Aug 4, 2021

I completely agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants