fix(qqbot): recognize GFM table separators with one or two dashes (#9… · openclaw/openclaw@d63389c
ly-wang19
·
2026-06-23
·
via Recent Commits to openclaw:main
File tree
extensions/qqbot/src/engine/messaging
| Original file line number | Diff line number | Diff line change |
|---|
@@ -46,6 +46,15 @@ describe("chunkQQBotMarkdownText", () => {
|
46 | 46 | ).toEqual([["| Id | Value |", "|---:|---|", "| 1 | alpha |", "| 2 | beta |"].join("\n")]); |
47 | 47 | }); |
48 | 48 | |
| 49 | +it("confirms a table when the separator uses one or two dashes, not only three", () => { |
| 50 | +// GFM delimiter cells need only one or more dashes; a sub-3-dash separator previously failed |
| 51 | +// recognition, so the header and all rows but the last were silently dropped on send. |
| 52 | +for (const separator of ["|--|--|", "|-|-|", "|:--|--:|"]) { |
| 53 | +const text = ["| Id | Value |", separator, "| 1 | alpha |", "| 2 | beta |"].join("\n"); |
| 54 | +expect(chunkQQBotMarkdownText(text, 200, baseChunker)).toEqual([text]); |
| 55 | +} |
| 56 | +}); |
| 57 | + |
49 | 58 | it("flushes a possible table header as text when the next block is not a separator", () => { |
50 | 59 | const chunker = createQQBotMarkdownChunker((text) => [text]); |
51 | 60 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -433,7 +433,10 @@ function isTableSeparatorLine(line: string): boolean {
|
433 | 433 | return false; |
434 | 434 | } |
435 | 435 | const cells = splitTableCells(line); |
436 | | -return cells.length > 0 && cells.every((cell) => /^:?-{3,}:?$/.test(cell.trim())); |
| 436 | +// GFM delimiter cells need only one or more hyphens (optionally colon-aligned), so accept "-+", |
| 437 | +// not "-{3,}": a valid 1/2-dash separator (e.g. |--|--|) was not recognized here, leaving the |
| 438 | +// header pending and silently overwritten by later rows so the table's header and rows vanished. |
| 439 | +return cells.length > 0 && cells.every((cell) => /^:?-+:?$/.test(cell.trim())); |
437 | 440 | } |
438 | 441 | |
439 | 442 | function splitTableCells(line: string): string[] { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。