mukuldang08 / gwtwiki

Automatically exported from code.google.com/p/gwtwiki
0 stars 0 forks source link

Html to wiki for embedded unordered lists adds an additional list item #155

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use the wikipedia converter to convert html to wiki

HTML2WikiConverter converter = new HTML2WikiConverter();
ToWikipedia toWikipedia = new ToWikipedia();

String html = "<p>Some text:</p>\n"
            + "<ul>\n<li>Level One - 1\n<ul>\n<li>Level two</li>\n</ul>\n</li>\n<li>Level One - 2</li>\n</ul>";

        converter.setInputHTML(html);

        String wiki = converter.toWiki(toWikipedia);

What is the expected output? What do you see instead?

Expected output:

Some text:

* Level One - 1
** Level two
* Level One - 2

Actual output:
Some text:

* Level One - 1
** Level two
*
* Level One - 2

The additional list item (single level deep) under level two causes a blank 
list item to display when rendered back into html. 

Repeating the process adds an additional li each time.

What version of the product are you using? On what operating system?

3.0.19, java 6, debian

Please provide any additional information below.

Original issue reported on code.google.com by oliver.e...@gmail.com on 28 Jan 2014 at 2:10

GoogleCodeExporter commented 8 years ago
Chasing this one down further...

HtmlCleaner.createDocumentNodes() loops round the parent nodes, and on line 
694, excludes content tokens that are equal to an empty string. It does not 
recursively loop round the child nodes, so the ListTag.getListLines() method 
includes the empty content nodes and adds the empty list item (line 72). I'm 
not sure what your preference is - make the document nodes recursive, or add 
additional checks to the ListTag class. I haven't checked other HtmlTag 
implementations to see if they would need similar checking.

Original comment by oliver.e...@gmail.com on 25 Feb 2014 at 5:25