-
Notifications
You must be signed in to change notification settings - Fork 441
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
Support |||- from YAML #289
Support |||- from YAML #289
Comments
Thanks for the report, this is a dup of a previous bug which is fixed on master. Perhaps another release is in order...
|
I'm curious to know why you want this? |
Oh sorry, should have searched the issues first. How feasible is it to
incorporate this new syntax to mean "chomp the final newline"?
…On Wed, Jan 18, 2017, 8:20 PM Dave Cunningham ***@***.***> wrote:
Thanks for the report, this is a dup of a previous bug which is fixed on
master. Perhaps another release is in order...
$ jsonnet -e '|||-
> abc
> |||'
STATIC ERROR: <cmdline>:1:1: Text block syntax requires new line after |||.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#289 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ALPcHVhB12ZLiNFIEcFYf4P3UirEjHEXks5rTuRwgaJpZM4LnN2z>
.
|
Pretty feasible I should think. I guess this is only useful if you only have one line? |
I'm struggling to understand why anyone would want to have a paragraph of text with no terminating \n :) |
The use case is visually concatenating two text blocks together:
If I want b to immediately follow a, I need to chomp the last newline in a. |
(Sorry for the late reply. Github often doesn't email me for issue and PR updates.) |
Ok that sounds reasonable. It is not hard to add the support. I think a reasonable approach is that the reformatter converts (without consent and with no way to turn it off)
to
With that mode of operation, the presence of a \n in the last byte of the string literal indicates whether |||- should be emitted by the formatter. In other words there is no other state needed to store whether or not |||- was used. Changes needed are simple:
After (1) one should be able to test the JSON output. However without (2) jsonnet fmt will produce code that does not parse. |
I know this is a pretty old issue... but is there still openness to adding this syntax? I'm aware that I really like the approach from #289 (comment). Edit: My use case for this is also that I'm trying to concatenate multiple multiline string literals without extra newlines in between. |
Resolves google/jsonnet#289 Companion PR to google/jsonnet#1175
This will send jsonnet spinning, consuming 100% of CPU:
Tested with v0.9.0.
I was trying to see if jsonnet supported chomping the final newline in text blocks similar to how it's done in YAML. Consider this both a bug report and a feature request :D
The text was updated successfully, but these errors were encountered: