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
320
stars
109
forks
source link
Improper Indentation of Ordered and Unordered Lists #166
Describe the bug
When converting HTML that contains ordered (ol) or unordered (ul) lists to OpenXML, the bullet points or numbered items are not indented correctly in the resulting Word document. Items appear aligned with the left margin instead of being indented.
Expected behavior
Ordered and unordered lists in the Word document should reflect the same indentation as seen in HTML rendering.
Repro
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml;
using HtmlToOpenXml;
using var stream = new MemoryStream();
using var document = WordprocessingDocument.Create(stream, WordprocessingDocumentType.Document);
var converter = new HtmlConverter(document.AddMainDocumentPart());
await converter.ParseBody("""
<p>unordered list:</p>
<ul>
<li>first list item</li>
<li>second list item</li>
</ul>
<p>ordered list:</p>
<ol>
<li>first list item</li>
<li>second list item</li>
</ol>
""");
document.Save();
File.WriteAllBytes("converted.docx", stream.ToArray());
Describe the bug When converting HTML that contains ordered (ol) or unordered (ul) lists to OpenXML, the bullet points or numbered items are not indented correctly in the resulting Word document. Items appear aligned with the left margin instead of being indented.
Expected behavior Ordered and unordered lists in the Word document should reflect the same indentation as seen in HTML rendering.
Repro
Screenshots HTML:
Converted: