| 211 | /// Get a preview of the content (first n characters) |
| 212 | #[pyo3(signature = (max_length=500))] |
| 213 | fn preview(&self, max_length: usize) -> String { |
| 214 | // Use char-based iteration to respect UTF-8 character boundaries |
| 215 | let char_count = self.inner.content.chars().count(); |
| 216 | |
| 217 | if char_count <= max_length { |
| 218 | self.inner.content.clone() |
| 219 | } else { |
| 220 | // Take the first max_length characters (not bytes) |
| 221 | let preview: String = self.inner.content.chars().take(max_length).collect(); |
| 222 | format!("{preview}...") |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /// String representation |
| 227 | fn __repr__(&self) -> String { |