question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can i stringify toml comment?

See original GitHub issue

hey iarna~ this parser is so convenient to convert between toml and JSOject. but i have one question about that how can i insert the toml comment when i use TOML.stringify method to convert one js object to toml text?

i will appreciate it if u can give me some advice. thx a lot.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
scriptcodedcommented, Jul 17, 2020

@iarna Perhaps. In my head the hard thing with comments is that they don’t have an unique identifier, which means that they can not be easily represented in a POJO. The first solution that came to me was to use random identifiers for comments. The issues with that are pretty obvious though, as there is a risk for collisions between comments and actual keys. Also, it’s not a very friendly interface for developers.

Another idea might be to tie comment to properties, and return a separate object containing comments. For example:

# names contains a list of usernames and their IRL names.
# Multiline?
[names]
"foo" = "Mr. Foo"
# Nested comment?
"bar" = "The big Bar"
// Return value from `toml.parse`
{
  "data": { /* The normal output */ },
  "comments": {
    "names": "names contains a list of usernames and their IRL names.\\nMultiline?",
    "names.bar": "Nested comment?"
  }
}
1reaction
iarnacommented, Apr 18, 2020

At this time, comments are not supported. The biggest limitation is just figuring out how this would be represented. It would be useful for someone interested to spend some time working up examples of how this might work… what the source object versus resulting TOML would look like, and vice-versa.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - How can i stringify toml comment? - - Bountysource
How can i stringify toml comment ?
Read more >
@scampersand/toml - npm
Start using @scampersand/toml in your project by running `npm i ... If an object TOML.stringify is serializing has a toJSON method then it ......
Read more >
Toml | npm.io
interpret, @iarna/toml, toml, cosmiconfig-toml-loader, gray-matter, tomlify-j0.4, convict, remark-frontmatter, toml-j0.4, pajv, micromark-extension-fr.
Read more >
TOML to JSON / Simon Willison | Observable
toml = Module {version: "1.35.3", parse: ƒ(source, specificationVersion, multilineStringJoiner, useBigInt, xOptions), stringify: ƒ(rootTable, options), ...
Read more >
toml - Rust - Docs.rs
use toml::Value; let value = "foo = 'bar'".parse::<Value>().unwrap(); assert_eq!(value["foo"].as_str(), Some ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found