Skip to content

Improper Indentation of Ordered and Unordered Lists #166

@can-oezkan

Description

@can-oezkan

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());

Screenshots
HTML:
image

Converted:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions