Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey Steve,
I wanted to share this work with you, in case you found it useful. Please ignore/reject it if you don't find that it fits with Penlight's goals.
This pull request includes
stringx.quote_string
and changes topretty.write
.quote_string
wraps a string such that reloading that string from a chunk of Lua code produces identical results:It provides the same facilities as
("%q"):format(str)
, plus:\n
.\n
at the beginning, if found.=
signs that is one greater than any long-quotes that are embedded into the string.The second, and highly related, changes were to pretty.write:
stringx.quote_string
instead of internal, literal methods.Finally, a small patch was added for pretty.number:
tostring
so that it returns123
instead of123.0
. Without this patch, pretty.number was broken.I also added tests and local function documentation, although this should be re-read and verified before accepting.