MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / pdfSanitize

Function pdfSanitize

src/cli/pdf-lite.ts:34–46  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

32
33/** Map common Unicode to Latin-1/ASCII so base-14 fonts can render it; strip the rest. PURE. */
34export 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. */
49export function pdfEscape(s: string): string {

Callers 2

pdf-lite.test.tsFile · 0.90
buildPdfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected