Hey I've been using Ben Foster's Migradoc extensions as well and had this same problem. This may not be perfect, but it worked well enough for me... Modify your HtmlConverter.cs and do the following:
First, add a global variable:
private int _nestedListLevel;
Next, add 2 new node handlers to the AddDefaultNodeHandlers() method:
nodeHandlers.Add("ul", (node, parent) =>
{
if (parent is Paragraph)
{
_nestedListLevel++;
return parent.Section;
}
_nestedListLevel = 0;
return parent;
});
nodeHandlers.Add("ol", (node, parent) =>
{
if (parent is Paragraph)
{
_nestedListLevel++;
return parent.Section;
}
_nestedListLevel = 0;
return parent;
});
Finally, change the "li" node handler to the following... NOTE, this removes some of the styling work that he did, but it made things less complicated for me and works just fine.. you can re-add that stuff if you want.
nodeHandlers.Add("li", (node, parent) =>
{
var listStyle = node.ParentNode.Name == "ul"
? "UnorderedList"
: "OrderedList";
var section = (Section)parent;
var isFirst = node.ParentNode.Elements("li").First() == node;
var isLast = node.ParentNode.Elements("li").Last() == node;
var listItem = section.AddParagraph().SetStyle(listStyle);
if (listStyle == "UnorderedList")
{
listItem.Format.ListInfo.ListType = _nestedListLevel%2 == 1 ? ListType.BulletList2 : ListType.BulletList1;
}
else
{
listItem.Format.ListInfo.ListType = _nestedListLevel % 2 == 1 ? ListType.NumberList2 : ListType.NumberList1;
}
if (_nestedListLevel > 0)
{
listItem.Format.LeftIndent = String.Format(CultureInfo.InvariantCulture, "{0}in", _nestedListLevel*.75);
}
// disable continuation if this is the first list item
listItem.Format.ListInfo.ContinuePreviousList = !isFirst;
if (isLast)
_nestedListLevel--;
return listItem;
});