@pipeworx/mcp-guam-code 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The ONE Guam-specific delta kept after folding this pack's pdf-text.ts
3
+ * fork into the shared extractor (fleet #2888 -> #2904). Everything else
4
+ * `gu-pdf-extract.ts` used to carry — literal strings routed through a
5
+ * font's /ToUnicode map, the overlong-/Length retry against trailing junk,
6
+ * and the fire-and-forget `inflate()` unhandled rejection — was folded into
7
+ * `shared/src/pdf-text.ts` itself because none of it was actually
8
+ * Guam-specific. This one piece genuinely is, so it has nowhere else to
9
+ * live:
10
+ *
11
+ * One embedded symbol font per chapter PDF (`...+WPTypographicSymbols`,
12
+ * used only for that chapter's curly quote marks) carries a `/ToUnicode`
13
+ * CMap that is itself WRONG in Guam's own published source file — code 1
14
+ * (meant to be a left double curly quote) maps to U+0041 ('A') and code 2
15
+ * (right curly quote) maps to U+0040 ('@'). Confirmed by eye against
16
+ * surrounding text: "ADirector of Public Safety@" in a raw extraction is
17
+ * exactly "“Director of Public Safety”" with those two codes substituted
18
+ * back — the unmistakably intended reading, reproduced by any PDF viewer's
19
+ * own copy-paste. This is a defect in the SOURCE PDF, not something a
20
+ * general-purpose extractor could detect from first principles, so it is
21
+ * corrected here by font name rather than generalized into the shared file.
22
+ *
23
+ * Pass this as `shared/src/pdf-text.ts`'s `fontCMapOverride` option — it is
24
+ * called with every font's own dictionary text and its freshly parsed
25
+ * `/ToUnicode` map, right before that map is used to decode any text, and
26
+ * may return a replacement map to override specific codes.
27
+ */
28
+ export function guamFontCMapOverride(fontDict: string, map: Map<number, number>): Map<number, number> | void {
29
+ if (!/WPTypographicSymbols/.test(fontDict)) return;
30
+ const fixed = new Map(map);
31
+ fixed.set(1, 0x201c);
32
+ fixed.set(2, 0x201d);
33
+ return fixed;
34
+ }