Page 1 of 1

XHtmlImporter strikethru style inheritence is wrong

PostPosted: Thu Jan 18, 2018 4:12 am
by solid
I have noticed that strikethrough styling is not correct when applied to parent objects in html. I have created a unit test with some basic html/CSS then I run it through the XhtmlImporter. The style on the resulting docx and html rendered in a browser (chrome in my case) are not the same. I am on the latest (3.3.6 at the time of this writing) docx4j and docx4j-xhtmlimporter libraries. The problem is that when strikethru is applied on a parent element, all children should inherit that text decoration unless they explicitly override them. That does not happen for table td (unless the content happens to be a link which is weird) and section bodies.

Is there a bug tracker where I can formally submit this bug? It should be easy to fix and add it to the regular battery of tests.

here is my unit test to verify my results:
Code: Select all
package test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.docx4j.convert.in.xhtml.XHTMLImporterImpl;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.junit.Test;


public class Docx4jCssComplianceTest {

    @Test
    public void testTableInheritsStrikeThru() throws Docx4JException, IOException {
        String html = "<html><head><style>\n .change_type_D, .change_type_D *, .change_type_D td  {"
     +"text-decoration: line-through; "
     +"}\n "
     +".change_type_D table, .change_type_D td, .change_type_D H1 {\n"
     +" text-decoration: inherit;\n"
     +"}\n</style></head><body><section>no styled </section><section class=\"change_type_D\"><H1>Should be strikenthru text</H1><p>styled paragraph text</p><table><tbody><tr><td>hello</td><td><a href=\"#\">link</a></td></tr></tbody></table></section></body></html>";
       
       FileUtils.writeStringToFile(new File("target/docx4j_css_test.html"), html);
        FileOutputStream fos = new FileOutputStream(new File("target/docx4j_css_test.docx"));
        WordprocessingMLPackage doc = WordprocessingMLPackage.createPackage();
       

        XHTMLImporterImpl xhtmlImporter = new XHTMLImporterImpl(doc);
       
        xhtmlImporter.setHyperlinkStyle("Hyperlink");
        doc.getMainDocumentPart().getContent().addAll(xhtmlImporter.convert(html, "http://localhost/"));

        doc.save(fos);
        fos.flush();
        fos.close();
    }

}

Re: XHtmlImporter strikethru style inheritence is wrong

PostPosted: Thu Jan 18, 2018 7:58 am
by jason
Bug/issue tracker is at https://github.com/plutext/docx4j-ImportXHTML/issues

May be related to https://github.com/plutext/docx4j-ImportXHTML/issues/32 NOT_INHERITED has to be changed to INHERITS?