How can I render \\n as newlines in <pre><code> elements?
I need to render the post's body as HTML, but as it is given to me, it has some "\n", "\r" and "\t" characters. How can I replace them with newlines, carriage return and tab characters respectively? For example:
<pre><code>@post.body</code></pre>
renders as:
<p>I am trying to send my kubernetes logs to s3 using logstash(v5.4.3) and logstash-output-s3 (5.0.7). logstash is creating logstash-programmatic-access-test-object but not the actual log files. Below are my input and output configurations.</p>\\n\\n<pre><code>input {\\n file {\\n # kubelet created symlinks to docker container logs\\n path => \"/var/log/containers/*.log\"\\n tags => [\"kubernetes\", \"docker\"]\\n sincedb_path => \"/var/log/containers/sincedb-kubernetes\"\\n }\\n}\\n\\noutput {\\n if \"kubernetes\" and \"docker\" in [tags] {\\n s3{\\n access_key_id => \"XXXXXXXXXX\"\\n secret_access_key => \"XXXXXXXXXXXXXXXXXXXXXXXX\"\\n region => \"us-east-1\"\\n bucket => \"nonapp-logs\"\\n size_file => 2048\\n time_file => 5\\n prefix => \"non-app-logs-%{+YYYY.MM.dd}\"\\n canned_acl => \"private\"\\n server_side_encryption => true\\n }\\n }\\n}\\n</code></pre>\\n
However, I want it as:
<p>I am trying to send my kubernetes logs to s3 using logstash(v5.4.3) and logstash-output-s3 (5.0.7). logstash is creating logstash-programmatic-access-test-object but not the actual log files. Below are my input and output configurations.</p>
<pre><code>input {
file {
# kubelet created symlinks to docker container logs
path => "/var/log/containers/*.log"
tags => ["kubernetes", "docker"]
sincedb_path => "/var/log/containers/sincedb-kubernetes"
}
}
output {
if "kubernetes" and "docker" in [tags] {
s3{
access_key_id => "XXXXXXXXXX"
secret_access_key => "XXXXXXXXXXXXXXXXXXXXXXXX"
region => "us-east-1"
bucket => "nonapp-logs"
size_file => 2048
time_file => 5
prefix => "non-app-logs-%{+YYYY.MM.dd}"
canned_acl => "private"
server_side_encryption => true
}
}
}
</code></pre>
Try using the simple_format
helper. https://apidock.com/rails/ActionView/Helpers/TextHelper/simple_format