Skip to content

Provide better methods for reading and editing whitespace/comments #7

@spyoungtech

Description

@spyoungtech

Right now, the only way to edit whitespace in the round-trip model is to directly edit the context attribute containing the whitespace/comment context.

This is potentially error-prone, as there is no validation that the results, when serialized, will produce a valid JSON5 text. The model also currently simply holds these as Strings of the whitespace and comments concattenated together, so there is also no distinction between productions that have contextual comments and productions that merely have contextual whitespace.

The only existing prior art I know of for this from personal use is from the Python projects ruamel.yaml which provides some useful methods for editing comments. e.g. set_start_comment, yaml_add_eol_comment, set_comment_before_after_key. This may be a reasonable model for providing similar methods in this crate.

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