Skip to content

Conversation

FBnil
Copy link
Owner

@FBnil FBnil commented Sep 25, 2017

I removed the regexp (although I had a working regexp, it seems PHP7 does not like multiple non-greedy patterns. The need to anchor the query to <?xml> is very dirty). So I implemented the findBlockStart() and findBlockEnd() that search upto a paragraph change <w:p>, This has been tested with LibreOffice generated docx (that features <w:p>) and real MSOffice documents (that features extra parameters, nb: <w:p w:rsidR="00AC46F7" w:rsidRDefault="00AC46F7" w:rsidP="00AC46F7">). As well as a few new testcases to cover the new functionality.

What is new?

  • Blocks with variables inside now expand like Rows, with #n at the end (and you can get the old behavior back with an extra parameter)
  • Block functions now return sensible information instead of void
  • you can throw exceptions if you can not find a block (enabled by an extra parameter)
  • getBlock() implemented
  • Multiple same named blocks behave as before (you can replace them one by one)

See also TemplateProcessorTest.php for the additional test cases

Todo: Tested under PHP 7.0.22 maybe try older versions too (although no PHP7-only have been used).

I removed the regexp (although I had a working regexp, it seems PHP7 does not like multiple non-greedy patterns. The need to anchor the query to <?xml> is very dirty). So I implemented the findBlockStart() and findBlockEnd() that search upto a paragraph change <w:p>, This has been tested with LibreOffice generated docx (that features <w:p>) and real MSOffice documents (that features extra parameters, nb: <w:p w:rsidR="00AC46F7" w:rsidRDefault="00AC46F7" w:rsidP="00AC46F7">). As well as a few new testcases to cover the new functionality.

What is new?
* Blocks with variables inside now expand like Rows, with #n at the end (and you can get the old behavior back with an extra parameter)
* Block functions now return sensible information instead of void
* you can throw exceptions if you can not find a block (enabled by an extra parameter)
* getBlock() implemented

See also TemplateProcessorTest.php for the additional test cases
@FBnil
Copy link
Owner Author

FBnil commented Sep 25, 2017

Ok, installed phpcs and had to fix a lot of styling errors. Will check out a new version with the fixes.

@FBnil FBnil closed this Sep 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant