I am storing old html markup in my database, tracking changes, and then trying to render the diff using Differ and the :html
format option.
The following code is successfully generated:
<table>
...
<tr>
<th style="width:60px; text-align:left;">
Owner:
</th>
<del class="differ">
<td>
<span id="someID">Previous Owner Name</span>
</td>
</del>
<ins class="differ">
<td>
<span id="someID">Current Owner Name</span>
</td>
</ins>
</tr>
...
</table>
Notice the <del>
and <ins>
tagged elements.
If I view the source, it looks fine.
But because apparently this would disrupt the table layout, all browsers seem to move these new elements to before the table. When I inspect the element, I get the following:
<del class="differ"> </del>
<ins class="differ"> </ins>
<table>
...
<tr>
<th style="width:60px; text-align:left;">
Owner:
</th>
<td>
<span id="someID">Previous Owner Name</span>
</td>
<td>
<span id="someID">Current Owner Name</span>
</td>
</tr>
...
</table>
I tried writing a custom Rails view helper to replace each <ins>
and <del>
with a <span>
, but the same thing happens.
Is there a way to style the table using elements like I am trying to do, or am I going to have to walk the dom and apply styles to each appropriate <td>
using javascript? I cannot replace the tables in the beginning because I don't control the source.
and inside of the? You can only have a or inside of a . Or could you do this: ? – David Brunow Dec 03 '12 at 01:07and
tags. A good strategy would probably be to first look for the nested elements, style them accordingly on whether they are inside
or, and then finally remove all
,
,
andtags that have already been processed. – alt.126 Dec 03 '12 at 02:42