Skip to content

Can I access and reconstruct all parsed information (including commends and whitespace)? #5

Description

@vi

Toml representation in src/types.rs seems to be simplified and not enough to constuct a tree of toml objects that produces original toml document with original formatting.

Is tomllib a proper library for the following application idea:

Convert toml to line-based format and back, like xml2, but for TOML instead of XML. Something like in this imaginary session:

$ cat test.toml
[section1]
var1="qwe"

var2=456
# A comment
var3 = [ "qqq" ]

$ cat test.toml | toml2lines
/section1/var1="qwe
/section1/#=
/section1/var2=456
/section1/#=# A comment
/section1/var3/0=qqq

$ cat test.toml | toml2lines | lines2toml
[section1]
var1="qwe"

var2=456
# A comment
var3 = [ "qqq" ]

$ cat test.toml | toml2lines | grep var3 | lines2toml
[section1]
var3 = [ "qqq" ]

Maybe making all things in src/internals/ast reachable by Serde and/or making them public API should make it possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions