Skip to content

fix(pdf): normalize Arabic presentation forms (RTL phase 1) - #2539

Open
Islam Al-Nashar (aslamalkarywk7) wants to merge 1 commit into
microsoft:mainfrom
aslamalkarywk7:fix-pdf-rtl-phase1
Open

Islam Al-Nashar (aslamalkarywk7) wants to merge 1 commit into
microsoft:mainfrom
aslamalkarywk7:fix-pdf-rtl-phase1

Conversation

@aslamalkarywk7

@aslamalkarywk7 Islam Al-Nashar (aslamalkarywk7) commented Sep 18, 2026 •

Copy link
Copy Markdown

Related to #2336 (Phase 1 of the plan proposed there).

Some PDF producers emit Arabic Presentation Forms (U+FB50-U+FDFF, U+FE70-U+FEFF) instead of standard letters, which breaks downstream matching and LLM extraction. PdfConverter now normalizes exactly those two ranges to standard Unicode (NFKC per character, so ligatures expand too); everything else passes through byte-identical. Applied as a post-processing stage next to the existing numbering merge, so all extraction paths are covered.

Out of scope for this phase (stated openly): full BiDi reading-order reconstruction and RTL table column handling need the reporter redacted fixtures offered in the issue (or a new bidi dependency) - proposed as Phase 2 once fixtures land.

Verification on the current head (0 behind main, 1 commit, 80 insertions across 2 files):

Suite PR branch main baseline
tests/test_pdf.py 37 passed 37 passed
tests/test_pdf_rtl.py (new) 5 passed —
total 42 passed 37 passed

The new fixtures use explicit escapes so they are encoding-proof. The 5 RTL tests are additive; the existing PDF suite is unchanged.

@aslamalkarywk7

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@aslamalkarywk7

Copy link
Copy Markdown
Author

Hi maintainers - the branch is now updated with main (clean merge, fix intact: PDF Arabic presentation-forms normalization plus 5 tests in test_pdf_rtl.py, all green locally).

Could you please review when you get a chance? Related to #2336 (Phase 1). Thanks!

@aslamalkarywk7

Copy link
Copy Markdown
Author

Hi maintainers — following up on this PR directly (my earlier status update was on #2336).

The branch is on top of the current main (0 behind, 1 commit, diff unchanged: _pdf_converter.py + test_pdf_rtl.py, 80 insertions).

Verified locally on head 4c11a0d:

Suite PR branch main baseline
tests/test_pdf.py 37 passed 37 passed
tests/test_pdf_rtl.py (new) 5 passed —
total 42 passed 37 passed

No regressions: the 5 new RTL tests are additive, and the existing PDF suite is unchanged.

The workflow runs for this commit are held at action_required (first-time-contributor approval), so CI cannot report on its own. Could a maintainer approve the runs so the result is visible?

Chien Yuan Chang (@chienyuanchang) — per your suggestion I kept the scope to presentation-form normalization only, and the reading-order / mixed-direction / table-association work is still open pending the redacted fixtures. I can share synthetic RTL fixtures (paragraphs, multi-column, mixed Arabic + numbers + URLs, legal identifiers) for a Phase 2 PR, or test against any redacted file the reporter shares — whichever is more useful.

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