I have the following raw text that I wrap in a <pre>
tag to salvage as much of the layout as possible:
<pre>
test
field 1 : Foo
longer field 2 : Bar
very long field 3 : FooBar
other text and values
</pre>
The field and values are separated by a tab char (\t) a colon and a tab char(\t).
I would like to align the colons so the rendered result would be:
test
field 1 : Foo
longer field 2 : Bar
very long field 3 : FooBar
other text and values
You'll find a jsfiddle here with my effort so far.
I don't have much control over the text but I tried to replace the \t:\t with a <span>
so I get some control with css styling but so far not much joy.
This is the javascript I use to replace the \t:\t with a span:
$('pre').html(
$('pre')
.html()
.split('\t:\t')
.join('<span class="tab"> : </span>'));
and added this css rule to float the <span>
but that
.tab {
background-color:red;
width: 10em;
display: inline-block;
text-align: right;
float: left;
}
renders the span
at the start of each new line. I've tried also position: absolute
to no avail.
What are my options to get the colons aligned?