OpenXmlRegex should ignore lastRenderedPageBreak (temporary layout marker does not represent any document text)#180
Merged
Conversation
…rker does not represent any document text)
Fix UnicodeMapper and OpenXmlRegex bugs regarding lastRenderedPageBreakFix/open xml regex bugs
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 6 to 7. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](actions/download-artifact@v6...v7) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
…ctions/download-artifact-7 Bump actions/download-artifact from 6 to 7
There was a problem hiding this comment.
Pull request overview
This pull request enhances OpenXmlRegex and UnicodeMapper to properly ignore lastRenderedPageBreak elements, which are temporary layout markers that don't represent actual document content. This ensures that text matching and processing operations work correctly even when these invisible markers are present in Word documents.
Changes:
- Modified UnicodeMapper.RunToString() to return an empty string for lastRenderedPageBreak elements
- Updated OpenXmlRegex to filter out lastRenderedPageBreak elements when processing run content
- Added comprehensive unit tests and integration tests to verify the fix
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| OpenXmlPowerTools/UnicodeMapper.cs | Added handling to ignore lastRenderedPageBreak elements by returning empty string |
| OpenXmlPowerTools/OpenXmlRegex.cs | Updated filtering logic to exclude lastRenderedPageBreak alongside rPr elements |
| OpenXmlPowerTools.Tests/UnicodeMapperTests.cs | Added test verifying that lastRenderedPageBreak is ignored in text extraction |
| OpenXmlPowerTools.Tests/OpenXmlRegexTests.cs | Added test verifying regex matching works despite lastRenderedPageBreak markers |
| OpenXmlPowerTools.Tests/DocumentAssemblerTests.cs | Added integration test using document with lastRenderedPageBreak |
| TestFiles/DA-lastRenderedPageBreak.xml | Added test data file for DocumentAssembler integration test |
| TestFiles/DA-lastRenderedPageBreak.docx | Added test document containing lastRenderedPageBreak elements |
| .github/workflows/dotnet.yml | Updated download-artifact action from v6 to v7 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public void CanMatchDespiteInvisibleLayoutMarkers() | ||
| { | ||
| XDocument partDocument = XDocument.Parse(LastRenderedPageBreakXmlString); | ||
| XElement p = partDocument.Descendants(W.p).Last(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.