TemplateProcessor::fixBrokenMacros picking up '$' dollar characters and strip_tags every thing after it breaking formatting
I Changed the regex to '|\$[{]{[^}]}|U' which seems to work in my use case.
Repeatable by putting a '$' symbol on its own. Anything beyond that will get bunched up together or corrupt the outputted word document.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
I had the same issue and struggled with it for a while. Your fix didn't seem to work for me, but what I ended up doing was replacing the '$' with the numeric character reference with a str_replace in the constructor before sending to the fixBrokenMacros function.
It's hacky but if someone else struggles with the same problem my solution was replacing this
$this->tempDocumentMainPart = $this->fixBrokenMacros($this->zipClass->getFromName($this->getMainPartName()));
with this
$text = str_replace('${','${',str_replace('$', '$', $this->zipClass->getFromName($this->getMainPartName())));
$this->tempDocumentMainPart = $this->fixBrokenMacros($text);
in the constructor of TemplateProcessor.
I don't want to touch my search-patterns (macros), so I change those back afterwards, also allowing the fixBrokenMacros function to work if i.e no end tag was given.
@jt6a74 Your regex worked for me 馃憤
@Shakagi Thnks a lot. It works for me 馃憤
Worked for me too. Thanks!
my fix seems to be simply removing the call to fixBrokenMacros.
$this->tempDocumentMainPart = $this->zipClass->getFromName($this->getMainPartName());
// $this->tempDocumentMainPart = $this->fixBrokenMacros($this->zipClass->getFromName($this->getMainPartName()));
Most helpful comment
I had the same issue and struggled with it for a while. Your fix didn't seem to work for me, but what I ended up doing was replacing the '$' with the numeric character reference with a str_replace in the constructor before sending to the fixBrokenMacros function.
It's hacky but if someone else struggles with the same problem my solution was replacing this
$this->tempDocumentMainPart = $this->fixBrokenMacros($this->zipClass->getFromName($this->getMainPartName()));with this
$text = str_replace('${','${',str_replace('$', '$', $this->zipClass->getFromName($this->getMainPartName())));$this->tempDocumentMainPart = $this->fixBrokenMacros($text);in the constructor of TemplateProcessor.
I don't want to touch my search-patterns (macros), so I change those back afterwards, also allowing the fixBrokenMacros function to work if i.e no end tag was given.
Ref numeric character references: