unindenting heredoc/multiline strings
atstp opened this issue · 5 comments
Multiline strings can be pretty nasty if they're meant to be user facing; multi-line strings are either ugly in code or ugly printed.
Currently, for a compromise, you'd either pass it through a (re-)replace
, trimming the lines, or join a bunch of vectors with newlines (cuerdas.core/unlines
🎉).
Something like multiline
would be great: It would take the the shortest newline-to-non-whitespace and trim that from every line.
as code, this
(cuerdas.core/multiline "this is an example
of what to expect with
a `multiline` function"
would return the string:
this is an example
of what to expect with
a `multiline` function
Would this be a good fit for cuerdas?
This library's gotten me oddly excited about strings. Thanks for bearing with all the issues i've posted!
I really like the functionality but I don't like the multiline
as function name, I think it should be something more shorter and more auto explained...
How about the changes below?
<<auto
would function as specified above<<custom
would accept a regex or string to trim?
<<auto
seems like the only necessary one, but in the implementation, we'd be building <<custom
, so we might as well expose it.
<<
seems like a proper and commonly known name for that stuff.
okay, sounds good.
On the end I have renamed this function to be <<-
in the same way as in heredoc.