From fb43fa6e11b404236b70ba1ffd215d23ea411a85 Mon Sep 17 00:00:00 2001 From: "Yurii.sio2" Date: Thu, 8 Nov 2018 19:46:22 +0200 Subject: [PATCH] Fix TemplateProcessor :: fixBrokenMacros; The current regex causes the loss of the original formatting of some documents after the variables have been overwritten. Replaces the current regex with one that resolves this problem. New regex from @brainwood /\$(?:\{|[^{$]*\>\{)[^}$]*\}/U The brainwood's pull request was rejected due to pipe regex delimiters "|" --- src/PhpWord/TemplateProcessor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 7a5eaf55bb..e0af589769 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -445,7 +445,7 @@ protected function fixBrokenMacros($documentPart) $fixedDocumentPart = $documentPart; $fixedDocumentPart = preg_replace_callback( - '|\$[^{]*\{[^}]*\}|U', + '/\$(?:\{|[^{$]*\>\{)[^}$]*\}/U', function ($match) { return strip_tags($match[0]); },