Page 1 of 1

Ordered list does not append the "." after numbering

PostPosted: Tue Nov 15, 2016 2:26 am
by pleft
Here is the sample code:

Code: Select all
public class PlainTests {

    static final String TEST_STRING = "<html><head>" +
            "</head>" +
            "<body>" +
            "<ol><li>a</li><li>b</li></ol>" +
            "</body>" +
            "</html>";
    public static void main(String[] args) throws ParserConfigurationException, Docx4JException {

        WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage(PageSizePaper.A4, true);

        XHTMLImporterImpl XHTMLImporterForContent = new XHTMLImporterImpl(wordMLPackage);
        wordMLPackage.getMainDocumentPart().getContent().addAll(XHTMLImporterForContent.convert(TEST_STRING, null));
        wordMLPackage.save(new File("test.docx"));
    }
}


the resulting docx instead of having "1. a" shows "1 a". The "." dot is vanished. The same applies for any "list-style-type" set in "XhtmlNamespaceHandler.css"

Re: Ordered list does not append the "." after numbering

PostPosted: Tue Nov 15, 2016 10:06 pm
by pleft
hi, I found the reason, it is in the final return statement of the method getLvlTextFromCSSListStyleType in the ListHelper class:

Code: Select all
private String getLvlTextFromCSSListStyleType(String listStyleType, int level) {
      
      if ( listStyleType.equals("disc")) {
         return "";
      }
      if ( listStyleType.equals("circle")) {
         return "o";
      }
      if ( listStyleType.equals("square")) {
         return "";
      }
      
      return "%"+level;
   }


it returns
Code: Select all
"%"+level

instead of
Code: Select all
"%"+level+"."


Is there any way to override this, apart from rebuilding the whole project from scratch?

Re: Ordered list does not append the "." after numbering

PostPosted: Sat Nov 19, 2016 12:01 am
by pleft
If anyone is interested I have forked the project and created a pull request to address this.

https://github.com/pleft/docx4j-ImportX ... -numbering

and

https://github.com/plutext/docx4j-ImportXHTML/pull/27

Re: Ordered list does not append the "." after numbering

PostPosted: Fri Jun 30, 2017 8:50 am
by laurenquintanilla
Will this fix be added to a future release? We are also seeing this issue.
Thanks