Document comparison doesn't work correctly, after conversion from html to word

I am converting two html document to word and then comparing them for revision changes. The comparison on the tables work correctly but the paragraphs with the work instructions in them doesn’t show the comparison correctly.
This is my comparison code in java

CompareOptions compareOptions = new CompareOptions();
compareOptions.setIgnoreFormatting(false);
compareOptions.setIgnoreHeadersAndFooters(false);
compareOptions.setGranularity(Granularity.WORD_LEVEL);
compareOptions.setTarget(ComparisonTargetType.NEW);
html1.compare(html2, "author", new java.util.Date(), compareOptions);

The html for old revision as below

<p>Test the Qty: 8 gear-rotor bond joints by holding Rotor and turning each Sun Gear with Torque Wrench (A) and appropriate Bond<br/>Test Aid. Reject Assembly if Input Gear slips.<br/>Test Short Rotor Assemblies with Bond Test Aid (B).<br/>Test Long Rotor Assemblies with Bond Test Aid (C).</p>
<p>&nbsp;</p>

The html for new revision is as below

<p><img src="https://grgrg55/FlexNet/Images/ProcessDocumentation/WorkInstructions_406e4f96-2a11-4a37-ab1b-5ae1c4434be9.jpg" width="16" height="15"> Test the <strong>Qty</strong>: 8 gear-rotor bond joints by holding <span style="text-decoration: underline;">Rotor </span>and turning each <span style="color: darkorange;">Sun Gear</span> with Torque Wrench <strong>(A)</strong> and appropriate Bond&nbsp;Test Aid. <span style="text-decoration: underline;"><strong>Reject</strong></span> Assembly if Input Gear slips.</p>
<p><br>Test the Short&nbsp;<strong>Rotor Assemblies</strong> with Bond Test Aid <strong>(B)</strong>.</p>
<p><br>Test the Long&nbsp;<strong>Rotor Assemblies</strong> with Bond Test Aid <strong>(C)</strong>.</p>

After compare aspose thinks the text inside first p tag is new and marks it as green in new revision.
Attaching the resultant pdf snapshot here.

Please help me to understand how the comparison actually works in aspose words.

@Alokk257 Unfortunately, I cannot reproduce the problem on my side using the latest 24.11 version of Aspose.Words. Here is the result of comparison of your HTML documents:
out.docx (8.7 KB)

Could you please save the output as DOCX and attach your output document here for our reference?

Code.zip (111.9 KB)

Please find the two htmls , my java code and the output doc.
comparison_result.docx (25.7 KB)

@Alokk257 Thank you for additional information. I tested with the following simplified code and the result looks correct:

Document v1 = new Document("C:\\Temp\\NovHtml1.html");
setDocumentPageSetup(v1);
Document v2 = new Document("C:\\Temp\\NovHtml2.html");
setDocumentPageSetup(v2);
CompareOptions compareOptions = new CompareOptions();
compareOptions.setIgnoreFormatting(false);
compareOptions.setIgnoreHeadersAndFooters(false);
compareOptions.setGranularity(Granularity.WORD_LEVEL);
compareOptions.setTarget(ComparisonTargetType.NEW);
v1.compare(v2, "AW", new Date(), compareOptions);
v1.save("C:\\Temp\\out.docx");

Here is the produced output: out.docx (15.4 KB)

As I can see you are using an old 24.9 version of Aspose.Words. Please try using the latest 24.11 version.

It seems like this is working, but the requirement is to highlight the inserted text as green color, deleted text with a red color, and any change in formatting highlight to a yellow color.
Keeping the original font color intact.
Also i am highlighting new images and deleted images.

I am doing this through the function i have written in my java code “collectAndHighlightRevisions”.
and then i am accepting the inserted revisions, then rejecting the deleted revisions.

I would highly appreciate if you let me know how to highlight the revision changes as per the requirement.

@Alokk257 Probably you can simply configure revision appearance in RevisionOptions:

Document v1 = new Document("C:\\Temp\\NovHtml1.html");
setDocumentPageSetup(v1);
Document v2 = new Document("C:\\Temp\\NovHtml2.html");
setDocumentPageSetup(v2);
CompareOptions compareOptions = new CompareOptions();
compareOptions.setIgnoreFormatting(false);
compareOptions.setIgnoreHeadersAndFooters(false);
compareOptions.setGranularity(Granularity.WORD_LEVEL);
compareOptions.setTarget(ComparisonTargetType.NEW);
v1.compare(v2, "AW", new Date(), compareOptions);

RevisionOptions opt = v1.getLayoutOptions().getRevisionOptions();
opt.setShowInBalloons(ShowInBalloons.NONE);
opt.setInsertedTextColor(RevisionColor.GREEN);
opt.setDeleteCellColor(RevisionColor.RED);
opt.setRevisedPropertiesColor(RevisionColor.YELLOW);

v1.save("C:\\Temp\\out.pdf");

Thanks for helping out, but RevisionOptions didn’t had any inbuilt function to highlight the texts which was my original requirement.
By Checking my code i understood where i was wrong, i was using Run to iterate through all revision nodes, and composite nodes.
By Removing the logic for the composite node in my functions, it works and gives the result i was expecting.

private static void highlightInsertedText(Node node, String greenColor) {
        if (node instanceof Run) {
            ((Run) node).getFont().getShading().setBackgroundPatternColor(Color.decode(greenColor));
        }
    }
    
    private static void highlightDeletedText(Node node, String redColor) {
    	if (node instanceof Run) {
        	Run run = (Run) node;
        	Color originalColor = run.getFont().getColor();
        	run.getFont().setStrikeThrough(true);
            run.getFont().setColor(originalColor);
            run.getFont().getShading().setBackgroundPatternColor(Color.decode(redColor));
        }
    }

@Alokk257 It is perfect that you managed to achieve what you need. Please feel free to ask in case of any further issues, we are always glad to help you.

Hi Alex,
I just tested today with new html data, and i just used the simple compare function without the additional code. Its giving a different result than what i was expecting or MS word comparison tool.

I am attaching the zip file with the html code and output document.
comparison_result.zip (134.4 KB)

The html from previous version:

<p>Attach Label (A) to Motor Pack Housing (B) in location shown below.</p>
<p><img src="https://picsum.photos/id/237/200/300"></p>
<p>Install Ground Cable (C), with screw (D) Torque screw to 7.8 in-lbs using Torque Driver (E). Ensure Correct Torque is<br>displayed on the controller</p>
<p>&nbsp;</p>
<p><img src="https://picsum.photos/id/237/200/300"></p>

The html from new version:

<p><strong>Attach <span style="color: gold;">Label (A)</span></strong> to <span style="text-decoration: underline;">Motor Pack Housing (B)</span> in location shown below.</p>
<p><img src="https://picsum.photos/id/237/200/300"></p>
<p>&nbsp;</p>
<p>Install the <strong>Ground Cable (C)</strong>, with screw (D) Torque screw to <strong>7.8 in-lbs</strong> using Torque Driver (E).</p>
<p>&nbsp;</p>
<p>Ensure the correct torque is displayed on the controller as expected.</p>
<p>&nbsp;</p>
<p><img src="https://picsum.photos/id/237/200/300"></p>
<p>&nbsp;</p>
<p><span style="color: gold;">Don't</span> forget to check <span style="text-decoration: underline;">the screws</span> are not <strong>stripped</strong></p>
<p><strong><img src="https://picsum.photos/id/237/200/300"></strong></p>
<p>&nbsp;</p>
<ul>
   <li><strong>Test 1</strong></li>
   <li><strong>Test 2</strong></li>
   <li><strong>Test 3</strong></li>
</ul>

The issue is in the line with text
Install Ground Cable (C), with screw (D) Torque screw to 7.8 in-lbs using Torque Driver (E). Ensure Correct Torque is displayed on the controller

@Alokk257
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27666

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks for creating the defect. Could you please let me know if this would be a quick fix if we get the paid support.
This solution needs to be delivered to our customer as soon as possible.

@Alokk257 Paid support services allows to push the issue upper in the queue. The issue is currently in analysis, once analysis is done we will be able to provide you more information regarding the issue.