Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

refactor(chat_pipeline): improve regex patterns for table parsing

wizardchen649c9d3dc9fb
diff --git a/internal/application/service/chat_pipeline/rerank.go b/internal/application/service/chat_pipeline/rerank.go
index 0196f53b6..a0d9b2dde 100644
--- a/internal/application/service/chat_pipeline/rerank.go
+++ b/internal/application/service/chat_pipeline/rerank.go
@@ -452,9 +452,11 @@ var (
// reLatexBlock matches block-level LaTeX ($$...$$).
reLatexBlock = regexp.MustCompile(`(?s)\$\$.*?\$\$`)
// reTableSep matches table separator rows like |---|---|.
- reTableSep = regexp.MustCompile(`(?m)^\s*\|[\s:|-]+\|\s*$`)
+ // Uses [ \t] instead of \s to avoid consuming newlines across rows.
+ reTableSep = regexp.MustCompile(`(?m)^[ \t]*\|[ \t:|-]+\|[ \t]*$`)
// reTableRow matches markdown table data rows like | col1 | col2 |.
- reTableRow = regexp.MustCompile(`(?m)^\s*\|(.+?)\|\s*$`)
+ // Uses [ \t] instead of \s to avoid consuming newlines across rows.
+ reTableRow = regexp.MustCompile(`(?m)^[ \t]*\|(.+?)\|[ \t]*$`)
// reHeadingPrefix matches leading # markers in headings.
reHeadingPrefix = regexp.MustCompile(`(?m)^#{1,6}\s+`)
// reBlockquote matches leading > markers.