Repository navigation
Conversation
Signed-off-by: asad saleem <156583018+asadsehto@users.noreply.github.com>
|
✅ DCO Check Passed Thanks @asadsehto, all your commits are properly signed off. 🎉 |
Merge Protections🟢 Merge protection satisfied — ready to merge. Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
AI triage (advisory)Checked commit The PR makes Topic labels added: CI safety: no concern found. A maintainer must still approve CI. Possible duplicates
1 related pull request(s) in the same code
The |
chrikrah
left a comment
There was a problem hiding this comment.
@asadsehto This looks good to merge. At d059c2a the issue's reproducer gives أ., أ. and १., and base msword_backend.py fails 49 of the 52 new cases.
$ pytest -q -n 4 tests/test_backend_msword.py tests/test_backend_msword_lists.py # git archive d059c2a, Python 3.12, docling.__file__ from the export
399 passed
$ (same command, msword_backend.py from base 40e490c)
49 failed, 350 passed
$ ruff check && ruff format --check # ruff 0.17.2, docling tests docs/examples scripts
979 files already formatted
$ ty check docling/backend/msword_backend.py # ty 0.0.33: 22 diagnostics, base 22
# not run: the full tests/ tree, tach, dprint
non-blocking: base exported a hindiNumbers list as a - list; its markdown is now one paragraph. docling-core keeps any marker matching \d+\. (markdown.py:425 on main), and \d matches Devanagari digits, which CommonMark rejects:
$ python -c 'from markdown_it import MarkdownIt; print(MarkdownIt("commonmark").render("१. a\n२. b\n"))'
<p>१. a
२. b</p>
decimalFullWidth has done the same since #4336, so I wouldn't hold this PR for it. The fix is [0-9]+\. in docling-core. Can you raise it there?
|
Thanks for the review @chrikrah! Raised it in docling-core as docling-project/docling-core#1098 and opened a fix: docling-project/docling-core#1099 |
List levels with
w:numFmtset toarabicAbjad,arabicAlphaorhindiNumberswere not in_VISIBLE_NUMBERING_FORMATS, so they were converted as bullets: everyListItemgotmarker=''and the numbers Word shows were lost.This adds the three formats to the visible set and renders their counters in
_format_enum_counter, next to the East Asian formats from #4336.ECMA-376 names these formats ("Arabic Abjad Numerals", "Arabic Alphabet", "Hindi Numbers") but does not list their characters, so the output follows what Microsoft Word 16.112 (macOS) renders. I read Word's markers back with "Convert numbers to text" for every counter from 0 to 112 in each format, and the new code matches all 339:
arabicAbjadarabicAlphahindiNumbersarabicAbjaduses the abjad order (أ ب ج د ه و ز ح ط ي ك ل م ن س ع ف ص ق ر ش ت ث خ ذ ض ظ غ) andarabicAlphathe alphabetical order (أ ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي). After the 28th letter both repeat it: 29 is two copies of the first letter, 57 three.arabicAbjadand after it forarabicAlpha, so repeated letters do not join. The markers keep it, so they match Word's text exactly.hindiNumbersuses Devanagari digits (U+0966 to U+096F), not Arabic-Indic digits.hindiNumbersgives०. Negative counters stay decimal, as in the other helpers.Resolves #5653
Checklist:
Review evidence:
Before, the reproducer in #5653 gives
ListItem ''and- پهريون نقطوfor all three formats. After:Tests (macOS, Python 3.12):
tests/test_backend_msword_lists.py:test_format_enum_counter_arabic_and_hindi_num_fmt(16 counters per format, expected strings taken from Word),test_arabic_and_hindi_formatters_keep_negative_values_decimal, andtest_list_markers_follow_arabic_and_hindi_num_fmt_end_to_end(a generated DOCX whose letter lists start at 28 so they cross the end of the alphabet, asserting the markers afterconvert()). 52 tests; 49 of them fail onmain.pytest tests/test_backend_msword.py tests/test_backend_msword_lists.py: 372 passed, 1 skipped (main: 320 passed; the difference is the 52 new tests). 13 tests fail and 13 error the same way onmainand on this branch, because my environment lacks the optional LaTeX dependency (NameError: UnicodeToLatexEncoder).ruff checkandruff format --check(0.17.2) on the changed files: pass.ty check docling/backend/msword_backend.py(0.0.33): 22 diagnostics, the same 22 as onmain.check_max_lines.py: pass.Not run: the full test suite and
make validate(tach, dprint).