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

issue #47 resolved #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

issue #47 resolved #48

wants to merge 2 commits into from

Conversation

Yogesh0627
Copy link

Pull Request Description: Fix for Infinite Recursion in move_children_forward_recursively for Long Continuous Words

Problem Description:
This pull request addresses a bug in the move_children_forward_recursively function, which resulted in infinite recursion when handling long continuous words that could not fit on a page. The original logic would attempt to move overflowing content to the next page, but for long continuous words without spaces, the content would still not fit, leading to an endless loop.

Solution Implemented:
In this fix, additional logic has been introduced to specifically handle long continuous words in the following way:

Long Word Detection:

A check is introduced to identify when a text node contains a long continuous word without spaces.
If such a word is detected, it is split into manageable parts.
Word Handling:

The word is split into segments, with the first portion remaining on the current page and the latter part being moved to the next page. This ensures that the content doesn't infinitely overflow and cause a recursive loop.
Recursive Handling:

New Changes Compared to Original Code:
Handling Long Continuous Words: A mechanism to detect and split long continuous words, which prevents the infinite recursion issue.
Graceful Word Wrapping: For long words that cannot fit on a single page, the content is split and moved across pages, rather than attempting to force the entire word onto the next page.
Preservation of Recursion Logic: The overall recursive movement and cloning logic remain intact but are now equipped to handle long text nodes without causing performance or overflow issues.
This fix effectively prevents infinite recursion when the library tries to move long continuous words between pages while preserving the functionality for other types of content like images, headers, and tables.

Testing & Verification:
This solution has been tested with various cases, including:

Long continuous words.
Regular text nodes with spaces.
Various HTML elements like headers, images, and tables.
The recursive handling for normal text and sub-child elements remains largely the same but includes safeguards to avoid the infinite loop when dealing with long words.
If a word is too long to fit on a single page, it is broken and moved piece by piece across pages.
Element Cloning & Movement:

Elements such as headers, images, or other non-text nodes are handled as before, being moved or cloned to the next page when required.
The recursive cloning process is maintained with the introduction of additional checks to ensure that long text nodes are handled properly and do not disrupt the flow of elements.

@Yogesh0627
Copy link
Author

i have optimized my approach for the solution

@Yogesh0627
Copy link
Author

hey can you please give feedback for my implementation for the solution .

@motla
Copy link
Owner

motla commented Sep 20, 2024

Hi @Yogesh0627
Thanks a lot for your contribution. I'm sorry these times are a bit complicated I'm overwhelmed with several due dates, but it's definitely in my todo list 👍
I hope I can check it soon.
Romain

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

Successfully merging this pull request may close these issues.

2 participants