Cleans up docling's list bullets that include original PDF bullets like '•', '-', or 'o'. Converts '- Text', '- - Text', etc. into '- Text'.
(content: str)
| 554 | return '\n'.join(out_lines), modified |
| 555 | |
| 556 | def fix_messy_bullets(content: str) -> tuple[str, int]: |
| 557 | """ |
| 558 | Cleans up docling's list bullets that include original PDF bullets like '•', '-', or 'o'. |
| 559 | Converts '- Text', '- - Text', etc. into '- Text'. |
| 560 | """ |
| 561 | lines = content.split('\n') |
| 562 | out = [] |
| 563 | modified = 0 |
| 564 | import re |
| 565 | bullet_pattern = re.compile(r'^(\s*-\s*)(?:-\s*|[•➢o]\s+)+(.*)$') |
| 566 | for line in lines: |
| 567 | m = bullet_pattern.match(line) |
| 568 | if m: |
| 569 | out.append(m.group(1) + m.group(2).strip()) |
| 570 | modified += 1 |
| 571 | else: |
| 572 | out.append(line) |
| 573 | return '\n'.join(out), modified |
| 574 | |
| 575 | def join_split_paragraphs(content: str) -> tuple[str, int]: |
| 576 | """ |