This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Allow indentation in multiline strings #35
Labels
Comments
Some ideas after a conversation with @jordwalke:
|
More information in this Reason issue: reasonml/reason#2603 |
Adding a few more keywords for searchability: strip leading spaces from multiline strings. |
Btw, in case it makes this easier to implement, I think this style would also be great: let str =
// Leading backtick character determines how many leading spaces to trim.
`
This is a
multiline string.
` |
ryyppy
added
bug
Something isn't working
enhancement
New feature or request
and removed
bug
Something isn't working
labels
May 2, 2022
The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It was discussed before but I am afraid that adding this later might introduce a breaking change. So making an issue here so the choice can be made to implement it early or there is a solution that is non-breaking.
Context: if multiline strings cannot be indented, multiline strings are not very friendly to use at all, as generally code is indented.
Proposal:
This means that in a multiline string there should always be a newline after the first backtick, with the last backtick indicating the indentation. Also pretty-printing can now shift strings in the right indentation.
Prior art is Elixir, Swift and Python, all adopting this style of multiline strings. Best docs here.
The only difference is that in some languages by default a newline is added on the last line. So that
Will actually be
this is a multiline string\n
(Elixir). I actually think this is not great because we can always explicitly add a newline if we want.Of course
is still valid if the backticks are both on the same line.
The text was updated successfully, but these errors were encountered: