purescript-contrib / purescript-formatters

Formatting and printing for numeric and date/time/interval values
Apache License 2.0
41 stars 29 forks source link

Placeholders don't escape. #70

Closed hexagonal-sun closed 1 year ago

hexagonal-sun commented 3 years ago

Describe the bug The Placeholder FormatterCommand doesn't escape when it's string is set to that of a different FormatCommand.

To Reproduce

> printFormatter $ fromFoldable [Placeholder "YYYY"]
"YYYY"

Then if we attempt to parse it back again:

> parseFormatString $ printFormatter $ fromFoldable [Placeholder "YYYY"]
(Right (YearFull : Nil))

Expected behavior The grammar for format strings should include some kind of an escape sequence so that if a user did want to use the string 'YYYY' in their output they could. Once that has been decided, formatString should then escape any Placeholders that contain a reserved string.