newline characters in tables during document parsing #7563

Closed
opened 2026-02-21 18:21:13 -05:00 by yindo · 1 comment
Owner

Originally created by @Hisir0909 on GitHub (Jan 7, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.14.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

in docx, use tables with newline characters.

✔️ Expected Behavior

success extract table

Actual Behavior

Originally created by @Hisir0909 on GitHub (Jan 7, 2025). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.14.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce in docx, use tables with newline characters. ### ✔️ Expected Behavior success extract table ### ❌ Actual Behavior ![](https://private-user-images.githubusercontent.com/76634394/398343931-77102ab6-f011-46b1-a8f5-d677cbbe94bb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzYyMzk5MzEsIm5iZiI6MTczNjIzOTYzMSwicGF0aCI6Ii83NjYzNDM5NC8zOTgzNDM5MzEtNzcxMDJhYjYtZjAxMS00NmIxLWE4ZjUtZDY3N2NiYmU5NGJiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTA3VDA4NDcxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY0NzM3NTJhOTIxM2U4YjNkMzViYWUzZDAxM2JjOWQ0YTAzZDhmODgxZDEzNGMxYzQyOWVkNTlhNGUwNTk5ZTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.9SeRsBPWGJG8OwJkGlY6mpdFnYHkeM2dk2eHYBxCNHI)
yindo closed this issue 2026-02-21 18:21:13 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 7, 2025):

To address the issue of extracting tables with newline characters in a DOCX document using Dify version 0.14.2, you can utilize the WordExtractor class. This class includes a method called parse_docx that processes DOCX files and extracts tables, converting them into Markdown format. The method handles tables by iterating over the document's elements and specifically processes tables using the _table_to_markdown method.

The _table_to_markdown method converts tables into Markdown format, ensuring that content is correctly parsed and formatted. It processes each row and cell, maintaining the structure of the table. Additionally, the parse_docx method appends a newline character (\n) to the content list when a paragraph is empty, ensuring that newlines are preserved in the output [1].

If you are encountering issues with newline characters not being handled as expected, ensure that your implementation of the WordExtractor class is correctly set up to process these elements. If the problem persists, you might want to check if there are any specific configurations or updates needed in your setup.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot[bot] commented on GitHub (Jan 7, 2025): <!-- Answer --> To address the issue of extracting tables with newline characters in a DOCX document using Dify version 0.14.2, you can utilize the `WordExtractor` class. This class includes a method called `parse_docx` that processes DOCX files and extracts tables, converting them into Markdown format. The method handles tables by iterating over the document's elements and specifically processes tables using the `_table_to_markdown` method. The `_table_to_markdown` method converts tables into Markdown format, ensuring that content is correctly parsed and formatted. It processes each row and cell, maintaining the structure of the table. Additionally, the `parse_docx` method appends a newline character (`\n`) to the content list when a paragraph is empty, ensuring that newlines are preserved in the output <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/rag/extractor/word_extractor.py)</sup>. If you are encountering issues with newline characters not being handled as expected, ensure that your implementation of the `WordExtractor` class is correctly set up to process these elements. If the problem persists, you might want to check if there are any specific configurations or updates needed in your setup. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/f6b001ba-f179-49b2-92ac-598fb1b5e3ea?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/f6b001ba-f179-49b2-92ac-598fb1b5e3ea?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/f6b001ba-f179-49b2-92ac-598fb1b5e3ea?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/f6b001ba-f179-49b2-92ac-598fb1b5e3ea?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f6b001ba-f179-49b2-92ac-598fb1b5e3ea?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/f6b001ba-f179-49b2-92ac-598fb1b5e3ea?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7563