New line text problem
Closed this issue · 8 comments
Since version 1.20.0, line breaks in command output are not displayed correctly, all text is displayed on a single line
Do you have a sample script to share on this issue? On which platform?
Same problem here. Simple Python Script
print(f"Line 1\nLine 2")
results in
Line 1 Line 2
expected
Line 1
Line 2
I can confirm this.
Using curl works fine.
Whith a browser as. client. It looks different.
hmmm .. so, not really a bug.
It is the way how the browser interprets the returned text.
A great thing would be to optionally add tags to ensure correct formating, if the request comes from a browser.
<!DOCTYPE html>
<html>
<body>
<pre>
... webhookd-output ...
as
multiline
</pre>
</body>
</html>
Maybe with help of this check:
func isBrowserRequest(userAgent string) bool {
browsers := []string{"Chrome", "Firefox", "Safari", "Edge", "Opera"}
for _, browser := range browsers {
if strings.Contains(userAgent, browser) {
return true
}
}
return false
}
I have also noticed a bit of weirdness with this release when it comes to line breaks, but I haven't been able to figure out the exact cause. I've personally seen it remove a line break in some cases and also add blank lines in other cases. This isn't a huge deal for me as I was able to work around this issue by simply returning the response as a JSON value.
Even in the example screenshot above, there's an extra line break added between Line 1
and Line 2
; with one \n
, there shouldn't be a blank line between those two.
Also, I'm not sure I like the idea of wrapping responses in HTML in a browser. If possible, I would personally rather have the completely raw response so that the page can be saved and not result in an HTML file.
Also, I'm not sure I like the idea of wrapping responses in HTML in a browser. If possible, I would personally rather have the completely raw response so that the page can be saved and not result in an HTML file.
Agree. Default behavior should be completly raw respose. As an option it would be nice to have HTML enclosed output for quick and dirty solutions.
Regarding HTML concern, you can rely on SSE events to get the RAW output stream, and have each event (aka lines) surrounded with an HTML tag. There's an example in this repo's tooling directory: tooling/html/console.html
Indeed, the 1.20 has an unexpected extra line break. It's fixed. Thanks for the report!