Fix paragraph chunking to ignore blank lines inside code fences

This commit is contained in:
Tyler Yust
2026-01-24 23:39:09 -08:00
committed by Peter Steinberger
parent 0975aa4a7c
commit c3f5b4c416
2 changed files with 19 additions and 0 deletions

View File

@@ -343,6 +343,17 @@ describe("chunkMarkdownTextWithMode", () => {
const text = "```js\nconst a = 1;\nconst b = 2;\n```\nAfter";
expect(chunkMarkdownTextWithMode(text, 1000, "newline")).toEqual([text]);
});
it("does not split on blank lines inside a fenced code block", () => {
const text = "```python\ndef my_function():\n x = 1\n\n y = 2\n return x + y\n```";
expect(chunkMarkdownTextWithMode(text, 1000, "newline")).toEqual([text]);
});
it("splits on blank lines between a code fence and following paragraph", () => {
const fence = "```python\ndef my_function():\n x = 1\n\n y = 2\n return x + y\n```";
const text = `${fence}\n\nAfter`;
expect(chunkMarkdownTextWithMode(text, 1000, "newline")).toEqual([fence, "After"]);
});
});
describe("resolveChunkMode", () => {