Hi

Is there a bug in QTextDocumentFragment::toHtml() when dealing with nested lists? The code below outputs the string correctly, but not after calling QTextDocumentFragment::toHtml()

Qt Code:
  1. int main(int argc, char *argv[]){
  2. // to demonstrate bug in QTextDocumentFragment when using nested lists
  3. QString htmlExample(QLatin1String("<ul><li>Toplevel_Item1</li><li>Toplevel_Item2<ul><li>Level2_Item1</li><li>Level2_Item2</li></ul></li></ul>"));
  4. qDebug() << "String:" << htmlExample;
  5. QTextDocumentFragment docFragment(QTextDocumentFragment::fromHtml(htmlExample));
  6. qDebug() << "QTextDocumentFragment:" << docFragment.toHtml();
To copy to clipboard, switch view to plain text mode 

Output is
String: "<ul><li>Toplevel_Item1</li><li>Toplevel_Item2<ul><li>Level2_Item1</li><li>Level2_Item2</li></ul></li></ul>"
QTextDocumentFragment: "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body>
<ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><!--StartFragment-->Toplevel_Item1</li>
<li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Toplevel_Item2</li></ul>
<ul type="circle" style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 2;"><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Level2_Item1</li>
<li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Level2_Item2<!--EndFragment--></li></ul></body></html>"

But </li>for Toplevel_Item2 should come after the nested list (i.e., after Level2_Item2).

The Output should look similar to:

- Toplevel_Item1
- Toplevel_Item2
>>> Level2_Item1
>>> Level2_Item2

Best

Al_