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

Problems with numeric lists in word document #406

Closed
VTSgit opened this issue Jun 17, 2024 · 5 comments
Closed

Problems with numeric lists in word document #406

VTSgit opened this issue Jun 17, 2024 · 5 comments

Comments

@VTSgit
Copy link

VTSgit commented Jun 17, 2024

I'm just getting acquainted with the library, and I have the problem, the essence of which is that in addition to this list, I have others, but the library perceives them incorrectly and makes their order different from what it is in the document itself. What are you suggesting maybe some part of the options TransformDocument or something else? If so, then it will not work with the entire document in my case, perhaps for the reason that I have several lists in the document, and I want to see them in the which they are in word

I have approximately the following code where parse is from 'html-react-parser' and does not affect this

export const Component = () => {
  const documentHTML= await mammoth.convertToHtml({ arrayBuffer: buffer });

  return (
      <div className={......}>
        <div className={.....}>{parse(documentHTML)}</div>
      </div>
    )
} 

in my case without using options:

1. .......
............
1. .......
3. ......
4. ....
5. .....
6. .....
   ............
1. ......

although it's all one big list in word.

screenshot:

image

example:
Microsoft Word (2).docx

@VTSgit VTSgit changed the title Problems with lists in word document Problems with numeric lists in word document Jun 17, 2024
@mwilliamson
Copy link
Owner

I believe this is a duplicate of #394?

@VTSgit
Copy link
Author

VTSgit commented Jun 18, 2024

I believe this is a duplicate of #394?

It seems to me that no, because there it would be possible to go through the entire document and correct it, but in my case I have text between the numbered lists and then other numbered lists.

By the way, I still don’t understand what is meant by this, how can I use it in options?

I noticed that you did not include the expected output HTML.

I think that this is what we need.

<ol> <li>Text 1</li> </ol> <p>Some text</p> <ol start="2"> <li>Text 2</li> </ol> <p>Some text</p> <ol start="3"> <li>Text 3</li> </ol>

@mwilliamson
Copy link
Owner

In that case, I think this is a duplicate of #121.

@VTSgit
Copy link
Author

VTSgit commented Jun 19, 2024

In that case, I think this is a duplicate of #121.

Yes, apparently the problem still remained even after merging this branch:
#132

I'm now on version 1.6.0, maybe this is the problem
UPD: updated to 1.8.0 the problem is still there

@mwilliamson
Copy link
Owner

The issue is that the indented paragraphs are not themselves part of the bullet so far as the original Word document is concerned. As described in #121, you could try one of:

  • using soft returns
  • applying a list continuation style to the paragraphs and adding an appropriate style mapping for that style
  • detecting the paragraphs from their indent using a document transform, applying a style to those paragraphs, and then adding an appropriate style mapping for that style.

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

2 participants