Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table row/column comparison issues - unwanted TD element added #48

Open
vijayraj-a opened this issue Jul 6, 2022 · 1 comment
Open

Comments

@vijayraj-a
Copy link

Compare old table html string with new table html string(insert/delete row and column) shows some additional td elements added and display like table row, column collapses

Please find sample html code below,
Before modify:

<table style="width: 100%;">
              <tbody>
                            <tr>
                                           <td style="width: 19.9828%;">This</td>
                                           <td style="width: 19.9828%;">is&nbsp;</td>
                                           <td style="width: 19.9828%;">a</td>
                                           <td style="width: 19.9828%;">sampe</td>
                                           <td style="width: 20.0000%;">for</td>
                            </tr>
                            <tr>
                                           <td style="width: 19.9828%;">html</td>
                                           <td style="width: 19.9828%;">diff</td>
                                           <td style="width: 19.9828%;">test</td>
                                           <td style="width: 19.9828%;">the</td>
                                           <td style="width: 20.0000%;">&nbsp; &nbsp;sample</td>
                            </tr>
              </tbody>
</table>

image

Table after modify:

<table style="width: 100%;">
              <tbody>
                            <tr>
                                           <td style="width: 49.9571%;">A1</td>
                                           <td style="width: 49.9571%;">A2</td>
                            </tr>
                            <tr>
                                           <td style="width: 49.9571%;">
                                                         <br>
                                           </td>
                                           <td style="width: 49.9571%;">cvc</td>
                            </tr>
                            <tr>
                                           <td style="width: 49.9571%;">A3</td>
                                           <td style="width: 49.9571%;">A5</td>
                            </tr>
              </tbody>
</table>

image

Output Result:

<table style="width: 100%;">
              <tbody>
                             <tr>
                                           <td style="width: 49.9571%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">This</del><ins style="background-color: #cfc;text-decoration: none;font-size:inherit !important; line-height: inherit !important;">A1</ins></td>
                                           <td style="width: 49.9571%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">is&nbsp;</del></td>
                                           <td style="width: 19.9828%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">a</del></td>
                                           <td style="width: 19.9828%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">sampe</del></td>
                                           <td style="width: 20.0000%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">for</del><ins style="background-color: #cfc;text-decoration: none;font-size:inherit !important; line-height: inherit !important;">A2</ins></td>
                             </tr>
                             <tr>
                                           <td style="width: 49.9571%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">html</del>
                                                         <br>
                                           </td>
                                           <td style="width: 49.9571%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">diff</del><ins style="background-color: #cfc;text-decoration: none;font-size:inherit !important; line-height: inherit !important;">cvc</ins></td>
                             </tr>
                             <tr>
                                           <td style="width: 49.9571%;"><ins style="background-color: #cfc;text-decoration: none;font-size:inherit !important; line-height: inherit !important;">A3</ins></td>
                                           <td style="width: 49.9571%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">test</del></td>
                                           <td style="width: 19.9828%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">the</del></td>
                                           <td style="width: 20.0000%;"><del style="color: #999;background-color:#FEC8C8;font-size:inherit !important; line-height: inherit !important;">&nbsp; &nbsp;sample</del><ins style="background-color: #cfc;text-decoration: none;font-size:inherit !important; line-height: inherit !important;">A5</ins></td>
                             </tr>
              </tbody>
</table>

image

Note: we have customized highlight logic alone

@svaaraniemi
Copy link

Yep, I see the same behavior: comparing HTML which contains table elements often creates a diff with invalid HTML. It would be cool to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants