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

Ordered List And UnOrdered List seems not work #59

Open
1 of 7 tasks
kaka1909 opened this issue Feb 27, 2025 · 2 comments
Open
1 of 7 tasks

Ordered List And UnOrdered List seems not work #59

kaka1909 opened this issue Feb 27, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@kaka1909
Copy link

kaka1909 commented Feb 27, 2025

Issue Description

Ordered List And UnOrdered List seems not work, it just appears as normal paragraph.

Steps to Reproduce

Just use the hello-world example in godocx-example project.
And the generated docx in the godocx-example has no List Effect either.

Image

Expected Behavior

Just like the demo.png
https://github.com/gomutex/godocx-examples/blob/main/demo.png

Actual Behavior

Environment Details

  • GoDocx Library Version:
  • Go Version:
  • Operating System:
    • Windows
    • macOS
    • Linux
  • Word Processor Used:
    • Microsoft Word
    • LibreOffice
    • Google Docs
    • Other (please specify)
  • Word Processor Version:

Sample Code

// Your sample code here

Additional Information

@kaka1909 kaka1909 added the bug Something isn't working label Feb 27, 2025
@spekulant
Copy link
Contributor

spekulant commented Feb 27, 2025

+1
Can't get the lists to work in v0.1.5. Came here to raise it as well. Here are some details I found comparing documents

The unordered list starts to work with the godocx-produced document if I add the following into the <w:pPr> section

<w:numPr>
<w:ilvl w:val="0"/>
<w:numId w:val="1"/>
</w:numPr>

Though it's not indented, so then if I also add the ind value in the same pPr section, it indents it as expected

<w:ind w:left="720" w:hanging="360"/>

And this is the final OOXML form of a list item that appears to work

<w:p>
<w:pPr>
+    <w:numPr>
+    <w:ilvl w:val="0"/>
+    <w:numId w:val="1"/>
+    </w:numPr>
+    <w:ind w:left="720" w:hanging="360"/>
    <w:pStyle w:val="List Bullet">
    </w:pStyle>
</w:pPr>
<w:r>
    <w:t>item2
    </w:t>
</w:r>
</w:p>

As for numbered lists, I can't get them to work, somehow the only difference should be the numId value:

-    <w:numId w:val="1"/>
+    <w:numId w:val="2"/>

But it doesn't appear to do the trick, it may be down to different schema versions, but the w schema I compared against appears to be the same version 🤷

goocx-produced document schema version

xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"

google-docs-produced document schema version

xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"

So just for reference, I tried the following for a numbered list but it produced an unordered list instead. The difference between the two is that this does not seem to require the ind tag to indent it, perhaps the pStyle does the trick here.

<w:p>
<w:pPr>
+    <w:numPr>
+    <w:ilvl w:val="0"/>
+    <w:numId w:val="2"/>
+    </w:numPr>
    <w:pStyle w:val="List Number">
    </w:pStyle>
</w:pPr>
<w:r>
    <w:t>Numbered item3
    </w:t>
</w:r>
</w:p>

Env details

grep "godocx" go.mod
	github.com/gomutex/godocx v0.1.5
go version
	go version go1.23.4 darwin/amd64

Word processors used

  • Google Docs
  • MacOS Spotlight Preview (just for quick preview)

@spekulant
Copy link
Contributor

Having experimented a bit more with a few documents, I think the issue is not just the Numering and Indent, but also the list identification that is consistently present in new Word Processors, like below:

google docs

+ <w:p w:rsidR="00000000" w:rsidDel="00000000" w:rsidP="00000000" w:rsidRDefault="00000000" w:rsidRPr="00000000" w14:paraId="00000001">
<w:pPr>
    <w:numPr>
       <w:ilvl w:val="0"/>
       <w:numId w:val="1"/>
    </w:numPr>
    <w:ind w:left="720" w:hanging="360"/>
    <w:rPr>
       <w:u w:val="none"/>
    </w:rPr>
</w:pPr>
+ <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
    <w:rPr>
       <w:rtl w:val="0"/>
    </w:rPr>
    <w:t xml:space="preserve">item1
    </w:t>
</w:r>
</w:p>

+ <w:p w:rsidR="00000000" w:rsidDel="00000000" w:rsidP="00000000" w:rsidRDefault="00000000" w:rsidRPr="00000000" w14:paraId="00000002">
<w:pPr>
    <w:numPr>
       <w:ilvl w:val="0"/>
       <w:numId w:val="1"/>
    </w:numPr>
    <w:ind w:left="720" w:hanging="360"/>
    <w:rPr>
       <w:u w:val="none"/>
    </w:rPr>
</w:pPr>
+ <w:r w:rsidDel="00000000" w:rsidR="00000000" w:rsidRPr="00000000">
    <w:rPr>
       <w:rtl w:val="0"/>
    </w:rPr>
    <w:t xml:space="preserve">item2
    </w:t>
</w:r>
</w:p>

MS Word

+ <w:p w14:paraId="44A2FF17" w14:textId="71A5AF8B" w:rsidR="002A5934" w:rsidRDefault="002A5934" w:rsidP="002A5934">
<w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
       <w:ilvl w:val="0"/>
       <w:numId w:val="1"/>
    </w:numPr>
    <w:rPr>
       <w:lang w:val="en-US"/>
    </w:rPr>
</w:pPr>
<w:r>
    <w:rPr>
    <w:lang w:val="en-US"/>
    </w:rPr>
    <w:t xml:space="preserve">Point 1 
    </w:t>
</w:r>
</w:p>

+ <w:p w14:paraId="6C6D5F18" w14:textId="0B0661EE" w:rsidR="002A5934" w:rsidRDefault="002A5934" w:rsidP="002A5934">
<w:pPr>
    <w:pStyle w:val="ListParagraph"/>
    <w:numPr>
       <w:ilvl w:val="0"/>
       <w:numId w:val="1"/>
    </w:numPr>
    <w:rPr>
       <w:lang w:val="en-US"/>
    </w:rPr>
</w:pPr>
<w:r>
    <w:rPr>
       <w:lang w:val="en-US"/>
    </w:rPr>
    <w:t>Point 2
    </w:t>
</w:r>
</w:p>

It'd appear we can choose whichever id option (int, hex) as long as it's consistent with the xmlns schemas choosen for the document.

An observation re word processors: in MS Word and Google Docs - without any list identification - the numbered lists appear as if they're 'global', ie. continue incrementing the same list even if separated by a paragraph.
Unordered lists are not visibly affected by this.

@gomutex the w14 appears to be ignorable in the document schemas definition, did you run into some similar issues with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants