-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update regexp used in cloneBlock operation in TemplateProcessor #1478
base: master
Are you sure you want to change the base?
Conversation
@babache Please provide a document that does not work |
I have change regex with other method using a specific method in class, when i can, i send my new commit |
@babache thanks, please also check against the latest code from de develop stream, your fix might not be needed anymore. |
I'm sorry but i dont' kwnow how i can send my solution. I use the branch develop and no develop_v1 |
Just to add to this, i'm also having problems with replaceBlock, which uses the same Regex. When you change the font of a template using MS Word, the <w:p w:rsidR="00DE14AC" w:rsidRPr="00660CA2" w:rsidRDefault="00DE14AC">
<w:pPr>
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00660CA2">
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
</w:rPr>
<w:t>${block1}</w:t>
</w:r>
</w:p>
<w:p w:rsidR="00DE14AC" w:rsidRPr="00660CA2" w:rsidRDefault="00DE14AC">
<w:pPr>
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00660CA2">
<w:rPr>
<w:rFonts w:ascii="Arial" w:hAnsi="Arial" w:cs="Arial"/>
</w:rPr>
<w:t>${/block1}</w:t>
</w:r>
</w:p> My simple solution was to add a space at the beginning of the regex: Edit: Could do something like this too... public function replaceBlock($blockname, $replacement)
{
$ret = preg_match(
// '/(<\?xml.*)(<w:p.*>\${' . $blockname . '}<\/w:.*?p>)(.*)(<w:p.*\${\/' . $blockname . '}<\/w:.*?p>)/is',
// changed here \/
'/(<\?xml.*)(<w:p(\s.*)?>\${' . $blockname . '}<\/w:.*?p>)(.*)(<w:p.*\${\/' . $blockname . '}<\/w:.*?p>)/is',
$this->tempDocumentMainPart,
$matches
);
if (isset($matches[4])) { // changed here <
$this->tempDocumentMainPart = str_replace(
$matches[2] . $matches[4] . $matches[5], // changed here <
$replacement,
$this->tempDocumentMainPart
);
}
} |
This is an old PR, and I'm having the same problem. Is there any chance this can get reworked and pulled into the main branch? |
2d9f999
to
e458249
Compare
Description
cloneBlock does not work with some model
Fixes #1477
Checklist: