Skip to content
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

preserve whitespace #56

Open
cbluth opened this issue May 2, 2020 · 2 comments
Open

preserve whitespace #56

cbluth opened this issue May 2, 2020 · 2 comments

Comments

@cbluth
Copy link

cbluth commented May 2, 2020

it would be nice to preserve the whitespace of the text, so that json and other code can be displayed properly

here is a small example:

$ echo '{"name":"John","age":30,"car":null }' | jq . 
{
  "name": "John",
  "age": 30,
  "car": null
}
$ echo '{"name":"John","age":30,"car":null }' | jq . | lzma -9 | base64 -w0 | xargs -0 printf "https://itty.bitty.site/#/%s\n"
https://itty.bitty.site/#/XQAAAAT//////////wA9goAXHC6LiZ8k/+gPMP0uVIsKF0XO/eG8LIQQnX2bPJLbQuKUidRTu0QGvv/8PjgA

here is another example:

$ curl -s 'https://raw.githubusercontent.com/alcor/itty-bitty/master/firebase.json' | lzma -9 | base64 -w0 | xargs -0 printf "https://itty.bitty.site/#/%s\n"
https://itty.bitty.site/#/XQAAAAT//////////wA9goAXHCuPyKg+IoS2I0XRh7YBElDvcCPwDBWV1j+4KczU5pZdf2oDzF3EKiBctbCcxX+9ZbM8T/0kWtn5FPTu8NFP+eorPRMtsI25Kq87f8KjkM1ttKxYJKTrFnqMFCM2FYkaLv/8hKmKSlysZ/JVgSuctek5bzdDoIPUtcLUKBPAm7Na237FNmePCrcEucVxQHpp0rT5Q2W357aPxQ5hx/9jsmINca2jGcyUpsQKrodzTzYGAneaVBQxWkFWAH/CVZWpY4h4Io+DmKcId/LcG/0Jz9s=
@Lord0fBytes
Copy link

I believe this has less to do with itty.bitty and more to do with how jr is formatting the output. I don't know jr very well, but in my tests it looks like it is adding the \n EOL char to the data. Browsers naturally cannot handle this. You would need to replace all the \n chars with <br> for the browser to handle it.

Examples:
Doesn't Work:
echo -e 'hello\nworld' | lzma -9 | base64 -w0 | xargs -0 printf "https://itty.bitty.site/#/%s\n"
https://itty.bitty.site/#/XQAAAAT//////////wA0GUnujd0WqmGEqzUJYWnr//01wAA=
The browser will just convert the \n to a space

Does Work:
echo -e 'hello<br>world' | lzma -9 | base64 -w0 | xargs -0 printf "https://itty.bitty.site/#/%s\n"
https://itty.bitty.site/#/XQAAAAT//////////wA0GUnujfhZ7p+6lHFjGZzGjsY///9cyAAA
The browser converts the <br> correctly

@alcor
Copy link
Member

alcor commented Jun 23, 2020

Or wrap the whole thing in a pre tag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants