I have an HTML page where I need to display some log messages. I had them wrapped in <pre></pre>
, but it seems to be interpreting the log messages as HTML, I want it to print it raw. I tried suggestions given in "Displaying raw text in HTML like a text editor" or "Prevent automatic line breaks in a <code> tag" or "How can I use CSS to preserve line breaks in an HTML <code> block?", but none work (they give same result as my original HTML.
Here is my HTML page:
code {
font-size: 14px;
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0;
}
body {
font-family: Arial;
}
<div>
<h3>pre and code:</h3>
<pre>
<code>
[2016-06-24 16:06:00]|DEBUG|...., details='#<hashie::mash worker_address="http://xxx.amazonaws.com:8081" worker_id="0000000008" worker_task_id="776f31e01c530134025722000b27033c:gather_source_file_info_task_1466784360">'
</code>
</pre>
</div>
<div>
<h3>only code:</h3>
<code>
[2016-06-24 16:06:00]|DEBUG|...., details='#<hashie::mash worker_address="http://xxx.amazonaws.com:8081" worker_id="0000000008" worker_task_id="776f31e01c530134025722000b27033c:gather_source_file_info_task_1466784360">'
</code>
</div>
<div>
<h3>only pre:</h3>
<pre>
[2016-06-24 16:06:00]|DEBUG|...., details='#<hashie::mash worker_address="http://xxx.amazonaws.com:8081" worker_id="0000000008" worker_task_id="776f31e01c530134025722000b27033c:gather_source_file_info_task_1466784360">'
</pre>
</div>
Here is what it renders on browser (latest Chrome in Mac):
pre and code:
[2016-06-24 16:06:00]|DEBUG|...., details='#'
only code:
[2016-06-24 16:06:00]|DEBUG|...., details='#'
only pre:
[2016-06-24 16:06:00]|DEBUG|...., details='#'
NOTE the missing hashie::mash
What I want it to print is:
[2016-06-24 16:06:00]|DEBUG|...., details='#<hashie::mash worker_address="http://xxx.amazonaws.com:8081" worker_id="0000000008" worker_task_id="776f31e01c530134025722000b27033c:gather_source_file_info_task_1466784360">'
I run into similar problems when the log contains some XML.