Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dots_ocr/utils/format_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ def clean_text(text: str) -> str:
if not text:
return ""

# Remove leading and trailing whitespace
text = text.strip()
# Remove trailing whitespace only. Preserve leading spaces to keep indentation
# for nested lists and code blocks intact (e.g., multi-level Markdown lists).
text = text.rstrip()

# Replace multiple consecutive whitespace characters with a single space
if text[:2] == '`$' and text[-2:] == '$`':
Expand Down