microsoft / microsoft/markitdown
bug: consecutive partial numbers (.1 followed by .2) wrongly merged into '.1 .2'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
Bug
In _merge_partial_numbering_lines() (_pdf_converter.py), when two partial MasterFormat-style numbers appear on consecutive lines, the function merges the first number with the second number instead of merging it with the actual text below.
Reproduction
`python
from markitdown.converters._pdf_converter import _merge_partial_numbering_lines
text = '.1\n.2\nContractor shall furnish all materials.\n.3\nWork shall comply with local codes.'
print(_merge_partial_numbering_lines(text))
`
Actual output:
.1 .2 Contractor shall furnish all materials. .3 Work shall comply with local codes.
Expected output:
.1 .2 Contractor shall furnish all materials. .3 Work shall comply with local codes.
Root cause
Line 47 in _pdf_converter.py merges the current partial number with the next non-empty line unconditionally — it never checks if that next line is itself a partial number.
Fix
Add one guard before merging:
python if j < len(lines) and not PARTIAL_NUMBERING_PATTERN.match(lines[j].strip()):
PR: #2113
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in _pdf_converter.py at _merge_partial_numbering_lines() and review the handling of the next non-empty line against PARTIAL_NUMBERING_PATTERN. Run the reproduction from the issue and verify that consecutive partial numbers remain separate while each number still merges with following text. The issue references PR #2113, so check that work before starting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100