Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSupport line breaks in alert descriptions #1121
Comments
This comment has been minimized.
This comment has been minimized.
|
For description we'd want raw, and pretty much everywhere else we'd want \n so I guess that means both. |
This comment has been minimized.
This comment has been minimized.
|
Looking into this, adding support for raw newlines seems easy (simply don't error on them within a string), but supporting escaped characters is going to be more difficult: the parser just stores the raw part of the input expression that constitutes the string, without doing any escape character interpretation. So if the input expression is
...the string node that will be stored will contain the literal value
...and not
We need a mechanism to actually interpret all the possible escape sequences. The escape lexing part we could copy from https://golang.org/src/go/scanner/scanner.go?s=931:1526#L364, but not sure where the actual interpretation happens yet. |
This comment has been minimized.
This comment has been minimized.
|
For our purposes, it seems cleanest to still let the lexer store the raw strings (as it does for any token it scans) and then do the escape interpretation in the parser (do a call to |
This comment has been minimized.
This comment has been minimized.
|
@fabxc does that sound good? Then I'd go ahead with that. |
This comment has been minimized.
This comment has been minimized.
|
Whatever makes things as we want them to in a clean way. On Tue, Sep 29, 2015 at 3:28 PM Julius Volz notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
This is going to (presumably) apply to the parser everywhere, so we probably want to think a little how it'll work on the expression browser etc. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I don't see any issues with that being handled the same everywhere (whether interactive expressions or rules). Ok, I'll get to this soon. |
This comment has been minimized.
This comment has been minimized.
|
@fabxc Since our user-exposed templating is already Go-based, wouldn't it be nicer to also use Go-style backticks for raw strings rather than Pythonesque triple quotes? They also need less lookahead logic ( The bigger question is whether we then also want to disable |
This comment has been minimized.
This comment has been minimized.
|
We have |
This comment has been minimized.
This comment has been minimized.
|
Hm yeah, I guess Looking at how to implement this, I've found https://golang.org/pkg/strconv/#Unquote, which would be pretty much reusable if we decide to do it the Go way. The exception would be single-quoted strings, which are runes in Go, but normal strings in Prometheus. These could be manually converted on-the-fly into double-quoted strings before applying |
This comment has been minimized.
This comment has been minimized.
|
We had issues with the I also don't think we want the rawness-behavior for those but really just the addition of multi-lines. |
This comment has been minimized.
This comment has been minimized.
|
The issue with But that introduced the bug that we have now (including tests that expect broken output), namely that escape sequences no longer work. I would rather not try to reimplement all the logic in |
This comment has been minimized.
This comment has been minimized.
|
Correction: the tests added in #685 were expecting the right thing, as that's in the lexer and still expected to be raw. But we'll need additional tests for the parser now to make sure that the escape sequences get handled correctly on that level. |
juliusv
added a commit
that referenced
this issue
Sep 30, 2015
juliusv
referenced this issue
Sep 30, 2015
Merged
Support escape sequences in strings and add raw strings #1132
juliusv
added a commit
that referenced
this issue
Oct 8, 2015
juliusv
closed this
in
#1132
Oct 8, 2015
juliusv
added a commit
that referenced
this issue
Oct 16, 2015
fabxc
added a commit
that referenced
this issue
Jan 11, 2016
This comment has been minimized.
This comment has been minimized.
prat0318
commented
Sep 26, 2017
|
I went throught the commit, but still couldn't figure out how should i put the |
This comment has been minimized.
This comment has been minimized.
|
@prat0318 Strings work basically like in Go. If you want newlines, you can either put
If that isn't visible in Slack, is it maybe because Slack expects HTML or something? Like a |
gouthamve
pushed a commit
to gouthamve/promql
that referenced
this issue
Mar 28, 2018
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 23, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
guoshimin commentedSep 28, 2015
From IRC: