DocumentAssembler, OpenXmlRegex, UnicodeMapper bugfixes #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request aims to fix erroneous handling of
lastRenderedPageBreak elements are included in DOCX files by Word when it saves, I guess as a sort of temporary placeholder to indicate where Word's layout engine last broke content across pages when it laid out the file. They do not represent any part of the document content itself. However, the OpenXmlRegex code was unable to match regexes when the match happened to include one of these elements. I traced the problem back to the implementation of UnicodeMapper.RunToString, where I added some code to ignore these lastRenderedPageBreak elements, and added a unit test to check for proper handling.
Also, Word has a certain way of handling the xml:space attribute on elements, but most of the OpenXmlPowerTools seem to be ignoring that attribute and its meaning. I added a helper method to UnicodeMapper that aims to emulate Word's behavior when converting from XML elements -> Unicode text strings, and a unit test to assert/explain the behavior. I also added code (and a unit test) to DocumentAssembler, so when it inserts content that may begin or end with intentional whitespace, the whitespace actually shows up in the DOCX file (instead of being ignored as it was before).