(s: string)
| 32 | |
| 33 | /** Map common Unicode to Latin-1/ASCII so base-14 fonts can render it; strip the rest. PURE. */ |
| 34 | export function pdfSanitize(s: string): string { |
| 35 | const map: Record<string, string> = { |
| 36 | '✅': '[OK]', '✓': 'v', '⛔': '[BLOCKED]', '❌': '[FAIL]', '🧾': '', '🔍': '', '🎬': '', '★': '*', |
| 37 | '—': '-', '–': '-', '…': '...', '·': '-', '→': '->', '←': '<-', '↑': '^', '↓': 'v', |
| 38 | '’': "'", '‘': "'", '“': '"', '”': '"', '≈': '~', '≥': '>=', '≤': '<=', '×': 'x', '€': 'EUR', |
| 39 | }; |
| 40 | let out = ''; |
| 41 | for (const ch of s) { |
| 42 | if (map[ch] !== undefined) { out += map[ch]; continue; } |
| 43 | out += ch.codePointAt(0)! <= 0xff ? ch : ''; |
| 44 | } |
| 45 | return out.replace(/ +/g, ' '); |
| 46 | } |
| 47 | |
| 48 | /** Escape PDF string-literal specials. PURE. */ |
| 49 | export function pdfEscape(s: string): string { |
no outgoing calls
no test coverage detected