-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Template Processor strips formatting with dollar signs present #1179
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
Comments
@cbloss Yes, known deal. There are several competing patches being offered that fix the problem. The solution I came up with to the
This way, if there is damage, it is local and your document can still be opened. edit: just updated to the last version I use.
|
Hey @FBnil ! I've been bit before with replacing vendor files so I already was extending your TemplateProcessor. I needed the zipClass to be public. I moved over the fixBroeknMacros from the new TemplateProcessor you linked me too. It works like a charm! I also had a a similar setImageValue function that worked a lot like the zipAddFromString that was suggested by another user. It's definitely a well requested feature. Thank you for saving the day!! 👍 |
This problem is cause by the fixBrokenMacros matching dollar signs to curly braces that they shouldn't be matched to. The function is in the TemplateProcessor class. A quick fix without editing any library files is to extend the TemplateProcessor class and override the fixBrokenMacros function as follows then use your extended class instead of the TemplateProcessor class as you normally would. Here is the code that I used:
This changes the regex to match only opening curly braces that occur after a greater than symbol (outside of a xml tag). Admittedly there is probably further work/improvements to the regex that could be done. This regex might be even better I am mainly trying to ensure that the pattern doesn't match curly braces that are within attributes on xml tags (such as my issue) and that it won't grab onto the next variables curly braces either. This issue caused several pages of a document to be matched and stripped of formatting for me and caused the docx to be un-openable with the following error:
|
Hello!
I've recently updated to PHP 7.1 and upgraded the PHPoffice/phpword package to: "^0.12.1|^0.13.0", I'm suddenly having issues with the Template Processor. I have a Word doc that features dollar signs that are NOT variables. I'm using, of course, setValue to update the variables and if it's near another $, it strips it. I've been experiencing it stripping tables and new lines. I was trying to follow the suggestion in this thread: #1022 but it doesn't work.
Is this a known deal?
The text was updated successfully, but these errors were encountered: