I have this dump raw plain text. I uploaded it into my site as is
➜ Desktop ping 198.54.120.122
PING 198.54.120.122 (198.54.120.122): 56 data bytes
64 bytes from 198.54.120.122: icmp_seq=0 ttl=35 time=85.655 ms
64 bytes from 198.54.120.122: icmp_seq=1 ttl=35 time=84.976 ms
64 bytes from 198.54.120.122: icmp_seq=2 ttl=35 time=85.856 ms
64 bytes from 198.54.120.122: icmp_seq=3 ttl=35 time=85.103 ms
^C
--- 198.54.120.122 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 84.976/85.397/85.856/0.368 ms
I query it back I got this
I dd() it out to test, meaning at this point, I didn't lost my new lines yet.
I've tried
str_replace('\r\n','<br>',$paste->raw);
and hoping to see rendering better
public function raw($uuid)
{
$paste = Paste::where('uuid', base64_decode($uuid))->first();
return str_replace('\r\n','<br>',$paste->raw);
}
Result
It rendering like this without newlines
PING 198.54.120.235 (198.54.120.235): 56 data bytes 64 bytes from 198.54.120.235: icmp_seq=0 ttl=35 time=85.655 ms 64 bytes from 198.54.120.235: icmp_seq=1 ttl=35 time=84.976 ms 64 bytes from 198.54.120.235: icmp_seq=2 ttl=35 time=85.856 ms 64 bytes from 198.54.120.235: icmp_seq=3 ttl=35 time=85.103 ms ^C --- 198.54.120.235 ping statistics --- 4 packets transmitted, 4 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 84.976/85.397/85.856/0.368 ms
You guys can even see it live : here
How would one achieve that? Should I use the front-end to style this?
Imagine, you view a raw file in GitHub
or gist , I'm trying to build a mini version of that, an ability to display what I uploaded, and quickly share with others via a link.
The link suggested above, doesn't answer what I am looking for.