File size: 423 Bytes
0017280
 
 
 
a6b3188
 
 
 
 
 
 
 
0017280
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""Reader for plain text files: .txt, .md, .json, .do"""


def read_text(file_path: str) -> list[dict]:
    try:
        with open(file_path, "r", encoding="utf-8", errors="replace") as f:
            text = f.read()
        if not text.strip():
            return []
        return [{"page": 1, "text": text.strip()}]
    except Exception as e:
        print(f"Warning: Could not read {file_path}: {e}")
        return []