@@ -18,6 +18,7 @@ import {
1818 type SectionResult ,
1919} from "./zip-baseline-fetcher" ;
2020import { buildBM25Index , searchBM25 , type BM25Index } from "./bm25" ;
21+ import { parseTableRow } from "./markdown-utils" ;
2122import type { RequestTracer } from "./tracing" ;
2223import pkg from "../package.json" ;
2324
@@ -154,27 +155,6 @@ export interface OrchestrateOptions {
154155 canonUrl ?: string ;
155156}
156157
157- // ──────────────────────────────────────────────────────────────────────────────
158- // Markdown table helpers
159- // ──────────────────────────────────────────────────────────────────────────────
160-
161- /**
162- * Parse a single markdown table row into trimmed cell values, preserving
163- * legitimately-empty middle cells. Only the leading and trailing empty strings
164- * produced by splitting a `| a | b |`-style row are stripped — a prior
165- * `.filter(c => c.length > 0)` approach also dropped empty interior cells,
166- * which silently collapsed the column count and caused `cols.length >= N`
167- * guards to misfire (e.g. a voice-dump row with an empty tiers cell).
168- */
169- function parseTableRow ( row : string ) : string [ ] {
170- const parts = row . split ( "|" ) ;
171- // Strip the leading empty produced by a leading `|`, if present
172- if ( parts . length > 0 && parts [ 0 ] . trim ( ) === "" ) parts . shift ( ) ;
173- // Strip the trailing empty produced by a trailing `|`, if present
174- if ( parts . length > 0 && parts [ parts . length - 1 ] . trim ( ) === "" ) parts . pop ( ) ;
175- return parts . map ( ( c ) => c . trim ( ) ) ;
176- }
177-
178158// ──────────────────────────────────────────────────────────────────────────────
179159// BM25 Index Cache (per-request, lazy)
180160// ──────────────────────────────────────────────────────────────────────────────
0 commit comments