Skip to content

Preserve comments through ConvertFrom-Yaml/ConvertTo-Yaml round-trip #28

Description

Why

ConvertFrom-Yaml discards all comments during parsing, and ConvertTo-Yaml has no concept of comments to emit, so a round-trip ConvertFrom-Yaml | ConvertTo-Yaml loses every # comment even though the YAML 1.2.2 spec treats comments as a valid presentation detail. A user editing a config file through this module should not have inline documentation silently deleted.

What

Preserve comments across a full round-trip:

$yaml | ConvertFrom-Yaml | ConvertTo-Yaml  # comments survive

This covers leading comments above a node, trailing comments on the same line as a key/value, and standalone comments between unrelated nodes.

Acceptance criteria

  • A YAML file with a representative mix of comment kinds round-trips through ConvertFrom-Yaml | ConvertTo-Yaml byte-equivalent (or content-equivalent ignoring whitespace normalisation)
  • Default behavior unchanged when comment preservation is not requested
  • Spec test 2.9 (Single Document with Two Comments) passes a round-trip assertion

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions