Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper Indentation of Ordered and Unordered Lists #166

Closed
can-oezkan opened this issue Oct 2, 2024 · 1 comment
Closed

Improper Indentation of Ordered and Unordered Lists #166

can-oezkan opened this issue Oct 2, 2024 · 1 comment

Comments

@can-oezkan
Copy link

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

onizet added a commit that referenced this issue Oct 7, 2024
@lofcz
Copy link

lofcz commented Oct 11, 2024

Verified 3bdee30 fixes this on a broader test:
image

@onizet onizet mentioned this issue Oct 16, 2024
@onizet onizet closed this as completed Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants