-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Text Replacement not working as Expected #147
Comments
I have tried using replacing the text in paragraph level also. It changes the style to the existing text.
|
Hi @manovasanth1227 is there any update or workaround you found? |
Hey @ArisNance.
Not sure if this will work in all cases. If you have any other thoughts on this solution, please share. |
@manovasanth1227 thanks for the quick response and solution. it's a nice workaround and I can confirm it works for my need. I really appreciate it friend! |
@satoryu any update on this ? |
@manovasanth1227 think you can try this instead of monkey patching it:
|
Describe the bug
Hi Team, I am looking to replace content or text that contains a specific pattern, such as {{sample}}. When I use the existing substitute method in the TextRun class, it appears to not be working.
Upon debugging the issue, I discovered that while reading the DOCX file, the nodes (specifically w:t elements) have been split into multiple tags.
For example, if the word is {{vorname}},
For Easy Explanation I will represent array of text_run object as like this: ['{{', 'v', 'orname', '}}'].
Consequently, when attempting to replace the text content using the substitute method, which checks the TextRun objects one by one, it misses the word that exists in the first place due to this splitting.
To Reproduce
Have content being edited multiple times in docx file, It will eventually break into multiple nodes as described above.
example
Sample docx file
sample.docx
Expected behavior
Correctly replace the text placeholder text( {{vorname}}, {{Manovasanth}} ) with the given replacement text
Environment
docx
gem version: [e.g 0.6.2]The text was updated successfully, but these errors were encountered: