HsYAML icon indicating copy to clipboard operation
HsYAML copied to clipboard

Inline trailing comments fail to round trip

Open TristanCacqueray opened this issue 5 years ago • 2 comments
trafficstars

It seems like the comment event is missing some information to indicate if it is inline or standalone:

key: "value" # a comment

Results in (after passing through YE.writeEvents YT.UTF8 . map eEvent . rights . YE.parseEvents

key: "value"
# a comment

The events are:

MappingStart Nothing Nothing Block
Scalar Nothing Nothing Plain "key"
Scalar Nothing Nothing DoubleQuoted "value"
Comment " a comment"
MappingEnd

Would it be possible to add an attribute to the Comment event to preserve its line position?

TristanCacqueray avatar Aug 01 '20 12:08 TristanCacqueray

Yes, some comment position related information is not preserved in a round trip. See https://hackage.haskell.org/package/HsYAML-0.2.1.0/docs/Data-YAML-Event.html#g:4 for more details.

vijayphoenix avatar Aug 01 '20 15:08 vijayphoenix

Thank you for the reference. Isn't this something that could be improved?

TristanCacqueray avatar Aug 01 '20 15:08 TristanCacqueray