I have a Unix Shell script which produces a plain text report. Horizontal alignment is achieved by inserting spaces so that the output appears to be in columns in the terminal.
Caption Caption Caption
-------- -------- --------
Line 1 value 1 value 2
Line 2 value b bla bla
Line 3 value 1 value 2
Line 4 value b bla bla
The report is automated to run regularly and a copy is sent via email. To make the formatting look right in a mail client I set the content-type to HTML and added <PRE>
pre-formatting tags around the entire message content.
This works well enough. However I would like to highlight certain lines, eg by changing the font to set the text and background color. How could I best do that?
I can replace the <PRE>
...</PRE>
with a span to set a Mono-width font but how do I retain the blank spaces to keep the column/table appearance?
I tried to use actual HTML tables but this only works in some mail clients, in others the same message is illegible because most of the text becomes strung out in a very narrow (1 to 3 characters wide) very tall column. Also setting formatting options on table attributes behave wildly different between the few email clients that I have available for my own testing!
<span>
s and set the appropriate inline style? Or perhaps<b>
(or<strong>
) in case the inline style is not honoured.<b><pre>Text Line Here</pre></b>
<span>
,<b>
and<strong>
elements inside a<pre>
element. You can use any inline element inside a<pre>
, but you cannot use block-level elements, so your example<b><pre>Text Line Here</pre></b>
would be invalid.