MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / splitAnalysisBlocks

Function splitAnalysisBlocks

src/components/FieldDetailView.tsx:80–99  ·  view source on GitHub ↗
(rawText: string)

Source from the content-addressed store, hash-verified

78const isSeparatorCell = (cell: string) => /^:?-{3,}:?$/.test(cell.trim());
79
80function splitAnalysisBlocks(rawText: string): AnalysisBlock[] {
81 const text = rawText.replace(/\\n/g, "\n");
82 const lines = text.split("\n");
83 const blocks: AnalysisBlock[] = [];
84 let markdownBuffer: string[] = [];
85 const flushMarkdown = () => { if (markdownBuffer.length) { blocks.push({ type: "markdown", content: markdownBuffer.join("\n") }); markdownBuffer = []; } };
86 for (let i = 0; i < lines.length; i += 1) {
87 if (!isTableRow(lines[i])) { markdownBuffer.push(lines[i]); continue; }
88 flushMarkdown();
89 const tableRows: string[][] = [];
90 while (i < lines.length && isTableRow(lines[i])) { tableRows.push(parseTableRow(lines[i])); i += 1; }
91 const hasSeparator = tableRows[1]?.every(isSeparatorCell);
92 if (hasSeparator) tableRows.splice(1, 1);
93 if (tableRows.length >= 2) blocks.push({ type: "table", rows: tableRows });
94 else markdownBuffer.push(...tableRows.map((row) => `| ${row.join(" | ")} |`));
95 i -= 1;
96 }
97 flushMarkdown();
98 return blocks;
99}
100
101function getCache<T>(key: string): Record<string, { data: T; timestamp: number }> {
102 try { const c = localStorage.getItem(key); return c ? JSON.parse(c) : {}; } catch { return {}; }

Callers 1

FieldDetailViewFunction · 0.85

Calls 3

isTableRowFunction · 0.85
flushMarkdownFunction · 0.85
parseTableRowFunction · 0.85

Tested by

no test coverage detected