Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new tag 'multiline'. #221

Closed

Conversation

alankm
Copy link
Contributor

@alankm alankm commented Mar 6, 2018

The new multiline tag works just like the existing 'commented' tag (i.e. multiline:"true"), and tells go-toml to marshal the value as a multi-line string. The tag currently has no impact on any non-string fields.

The new multiline tag works just like the existing 'commented' tag (i.e. `multiline:"true"`), and tells go-toml to marshal the value as a multi-line string. The tag currently has no impact on any non-string fields.
@alankm
Copy link
Contributor Author

alankm commented Mar 6, 2018

During development for some of our projects we found that we wanted to enable users to provide substantial amounts of multi-line data in a TOML file. TOML supports this natively via triple-quotes ("""My multiline data."""), but does not require a parser to preserve this formatting. This behaviour resulted in a poor user-experience whenever we needed to modify data within a TOML file programmatically since large amounts of easily readable information would be condensed into an unreadably large single-line string with escape characters (eg: '\n') instead of real formatting.

I have addressed this issue by forking your library and adding in a new struct field tag "multiline", that carries a boolean much like your "commented" tag. This tag only has any effect on string primitives, so you may wish to review and alter the implementation to make it better fit within the library as a whole.

I believe that none of the changes I've made break backwards compatibility, and all unit tests are succeeding. Every location in the code where I have added or modified lines is marked with a note that can be found by searching for "// alankm NOTE: ".

pelletier pushed a commit that referenced this pull request Jun 5, 2018
The new multiline tag works just like the existing 'commented' tag (i.e.
`multiline:"true"`), and tells go-toml to marshal the value as a
multi-line string. The tag currently has no impact on any non-string
fields.
@pelletier
Copy link
Owner

Very sorry I dropped the ball on that! Merged in c01d127

@pelletier pelletier closed this Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants