Repository navigation
fix(rag): detect Markdown tables without body rows #1545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
embrace897
wants to merge
7
commits into
VoltAgent:main
Choose a base branch
from
embrace897:fix/rag-table-first-row
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3b8c880
fix(rag): detect Markdown tables without body rows
embrace897 9be3faf
fix(rag): require an adjacent Markdown table delimiter
embrace897 7c3fb8c
fix(rag): allow a missing trailing pipe in table delimiters
embrace897 223b29c
fix(rag): validate Markdown table delimiter cells
embrace897 50caaee
fix(rag): preserve table indentation and escaped header pipes
embrace897 455ed08
fix(rag): ignore an initial BOM during table detection
embrace897 e904a7c
fix(rag): support optional outer pipes and single-hyphen table delimi…
embrace897 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@voltagent/rag": patch | ||
| --- | ||
|
|
||
| Recognize header-only Markdown tables at the beginning of a document with either LF or CRLF line endings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { detectFormat } from "./format-detector"; | ||
|
|
||
| describe("Markdown table detection", () => { | ||
| it.each(["\n", "\r\n"])("detects a table with only a header and delimiter (%j)", (newline) => { | ||
| const table = ["| Name | Value |", "| --- | --- |"].join(newline); | ||
|
|
||
| expect(detectFormat(table)).toBe("table"); | ||
| }); | ||
|
|
||
| it("treats a pipe row without a delimiter as text", () => { | ||
| expect(detectFormat("| Name | Value |")).toBe("text"); | ||
| }); | ||
|
|
||
| it.each(["\n", "\r\n"])("accepts a delimiter without a trailing pipe (%j)", (newline) => { | ||
| const header = "| Name | Value |"; | ||
| const delimiter = "| :--- | ---:"; | ||
|
|
||
| expect(detectFormat([header, delimiter].join(newline))).toBe("table"); | ||
| expect(detectFormat([header, delimiter, "| one | two |"].join(newline))).toBe("table"); | ||
| }); | ||
|
|
||
| it.each(["\n", "\r\n"])("accepts aligned delimiter cells (%j)", (newline) => { | ||
| const table = ["| Name | Value |", "| :--- | ---: |"].join(newline); | ||
|
|
||
| expect(detectFormat(table)).toBe("table"); | ||
| }); | ||
|
|
||
| it("does not match an unrelated delimiter in prose", () => { | ||
| expect(detectFormat("| note |\nprose containing | -- | marker")).toBe("text"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.