@@ -5,6 +5,17 @@ import { SourceInfo } from '@/app/main/chatSection/types/source';
55import { hasLatex , processLatexInText } from '@/app/_common/components/chatParser/ChatParserLatex' ;
66import { processInlineMarkdownWithCitations } from '@/app/_common/components/chatParser/ChatParserCite' ;
77
8+ /**
9+ * 비표준 파이프 문자를 표준 Markdown 파이프(|)로 정규화
10+ * U+2223 (DIVIDES), U+2502 (BOX DRAWINGS LIGHT VERTICAL) 등을 ASCII 파이프로 변환
11+ */
12+ export const normalizeTableSeparators = ( text : string ) : string => {
13+ return text
14+ . replace ( / \u2223 / g, '|' ) // ∣ (DIVIDES) → |
15+ . replace ( / \u2502 / g, '|' ) // │ (BOX DRAWINGS LIGHT VERTICAL) → |
16+ . replace ( / \uFF5C / g, '|' ) ; // | (FULLWIDTH VERTICAL LINE) → |
17+ } ;
18+
819/**
920 * 테이블 구분자 라인인지 확인하는 헬퍼 함수
1021 * (예: |:---|:---:|---:|)
@@ -333,23 +344,28 @@ export const parseSimpleMarkdown = (
333344 }
334345
335346 for ( let i = 0 ; i < processedLines . length ; i ++ ) {
336- const line = processedLines [ i ] ;
347+ const line = normalizeTableSeparators ( processedLines [ i ] ) ;
337348 const key = `${ startKey } -block-${ i } ` ;
338349
339350 // --- 테이블 파싱 로직 (추가된 부분) ---
340351 const isTableLine = ( str : string ) => str . trim ( ) . includes ( '|' ) ;
341352 const isTableSeparator = ( str : string ) => / ^ \s * \| ? ( \s * : ? - + : ? \s * \| ) + ( \s * : ? - + : ? \s * \| ? ) \s * $ / . test ( str . trim ( ) ) ;
342353
343- const nextLine = processedLines [ i + 1 ] ;
354+ const nextLine = processedLines [ i + 1 ] ? normalizeTableSeparators ( processedLines [ i + 1 ] ) : undefined ;
344355 if ( isTableLine ( line ) && nextLine && isTableSeparator ( nextLine ) ) {
345356 const headerLine = line ;
346357 const separatorLine = nextLine ;
347358 const bodyLines = [ ] ;
348359
349360 let tableEndIndex = i + 2 ;
350- while ( tableEndIndex < processedLines . length && isTableLine ( processedLines [ tableEndIndex ] ) && ! isTableSeparator ( processedLines [ tableEndIndex ] ) ) {
351- bodyLines . push ( processedLines [ tableEndIndex ] ) ;
352- tableEndIndex ++ ;
361+ while ( tableEndIndex < processedLines . length ) {
362+ const normalizedLine = normalizeTableSeparators ( processedLines [ tableEndIndex ] ) ;
363+ if ( isTableLine ( normalizedLine ) && ! isTableSeparator ( normalizedLine ) ) {
364+ bodyLines . push ( normalizedLine ) ;
365+ tableEndIndex ++ ;
366+ } else {
367+ break ;
368+ }
353369 }
354370
355371 // 정렬 처리 (이제 separatorLine은 항상 정의되어 있음)
0 commit comments