onizet / html2openxml

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments into templated Word.
MIT License
321 stars 109 forks source link

Creating too many NumberingInstances for unordered lists #46

Closed BenGraf closed 5 years ago

BenGraf commented 5 years ago

Im composing a large OpenXML document from many HTML fragments, that contain lots of unorderd lists. It seems html2openxml appends a new NumberingInstance for each opening tag (<ul>), which might be correct, but more than really necessary. I'm facing an issue with Microsoft-Word, when trying to open the document, because it cannot cope with the thousands of NumberingInstances (showing an "out of memory" error.) I already tried to tweak HtmlToOpenXml.NumberingListStyleCollection.BeginList() to create only one NumberingInstance per nesting level, but ended in messing up the numbered lists.

Nofixfor_NumberingListStyleCollectionl.txt

BenGraf commented 5 years ago

I suggested a pull-request #53 that solved the issue for me.

BenGraf commented 5 years ago

Thanks for merging it to the dev branch!