(value: Any, limit: int)
| 66 | |
| 67 | |
| 68 | def truncate(value: Any, limit: int) -> str: |
| 69 | text = json.dumps(value, ensure_ascii=False) if isinstance(value, (list, dict)) else str(value or "") |
| 70 | text = " ".join(text.split()) |
| 71 | if len(text) <= limit: |
| 72 | return text |
| 73 | return text[: max(0, limit - 3)] + "..." |
| 74 | |
| 75 | |
| 76 | def paper_url_from_record(paper: Dict[str, Any]) -> str: |