From 9df659e7acaf51d7569e97f5ce5e2b973e78e315 Mon Sep 17 00:00:00 2001 From: Danny Lathouwers Date: Tue, 5 Aug 2025 14:19:49 +0200 Subject: [PATCH 1/4] Text splitter bugfixes * additional hardening against running on windows (removing instances of "\r" from the text to be split) for the text splitters that did not already have this. * fixed a bug in the MarkdownHeaderTextSplitter where the header breadcrumb line was not losing the proper number of segments on depth reduction (it only ever removed 1 segment, regardless of how much less deep the next header was than the previous one). * added a test to validate that abovementioned bug was fixed. --- .../src/Text/CharacterTextSplitter.cs | 2 + .../src/Text/MarkdownHeaderTextSplitter.cs | 2 +- .../Text/RecursiveCharacterTextSplitter.cs | 2 + .../test/Resources/markdown_test_material.md | 71 +++++++++++++++++++ .../Abstractions/test/Tests.MarkdownHeader.cs | 65 +++++++++++++++++ 5 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 src/Splitters/Abstractions/test/Resources/markdown_test_material.md diff --git a/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs b/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs index b53d958d..ec9e5b7d 100644 --- a/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs @@ -15,6 +15,8 @@ public override IReadOnlyList SplitText(string text) { text = text ?? throw new ArgumentNullException(nameof(text)); + text = text.Replace("\r", ""); // some people are using windows + List splits; if (separator != null) { diff --git a/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs b/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs index 18a4b706..67390e2d 100644 --- a/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs @@ -76,7 +76,7 @@ public override IReadOnlyList SplitText(string text) { var existingHeader = currentHeader.Split('|'); - string prevHeader = string.Join("|", existingHeader.Take(existingHeader.Length - 1)); + string prevHeader = string.Join("|", existingHeader.Take(existingHeader.Length - (1 - hLen + currentHeaderLen))); currentHeader = prevHeader + "|" + strippedLine.TrimStart('#').Trim(); currentHeaderLen = hLen; continue; diff --git a/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs b/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs index 4e96e87f..85fcb75f 100644 --- a/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs @@ -19,6 +19,8 @@ public override IReadOnlyList SplitText(string text) { text = text ?? throw new ArgumentNullException(nameof(text)); + text = text.Replace("\r", ""); // some people are using windows + List finalChunks = new List(); string separator = _separators[_separators.Count - 1]; diff --git a/src/Splitters/Abstractions/test/Resources/markdown_test_material.md b/src/Splitters/Abstractions/test/Resources/markdown_test_material.md new file mode 100644 index 00000000..a5ef2b3c --- /dev/null +++ b/src/Splitters/Abstractions/test/Resources/markdown_test_material.md @@ -0,0 +1,71 @@ +# Header A + +Text A + +## Header A.A + +Text A.A + +## Header A.B + +Text A.B + +### Header A.B.A + +Text A.B.A + +### Header A.B.B + +Text A.B.B + +### Header A.B.C + +Text A.B.C + +## Header A.C + +Text A.C + +### Header A.C.A + +Text A.C.A + +### Header A.C.B + +Text A.C.B + +# Header B + +Text B + +## Header B.A + +Text B.A + +## Header B.B + +Text B.B + +### Header B.B.A + +Text B.B.A + +### Header B.B.B + +Text B.B.B + +## Header B.C + +Text B.C + +### Header B.C.A + +Text B.C.A + +### Header B.C.B + +Text B.C.B + +### Header B.C.C + +Text B.C.C \ No newline at end of file diff --git a/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs b/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs index 42f74eda..603fd88d 100644 --- a/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs +++ b/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs @@ -61,4 +61,69 @@ Hi this is Joe res[0].Should().Be("Hi this is Jim\nHi this is Joe"); res[1].Should().Be("Hi this is Molly"); } + + [Test] + public void TestMarkdown4() + { + var md = H.Resources.markdown_test_material_md.AsString(); + + var splitter = new MarkdownHeaderTextSplitter(); + var res = splitter.SplitText(md); + + res.Count.Should().Be(18); + + res[0].Split("\n")[0].Should().Be("Header A"); + res[0].Split("\n")[1].Should().Be("Text A"); + + res[1].Split("\n")[0].Should().Be("Header A: Header A.A"); + res[1].Split("\n")[1].Should().Be("Text A.A"); + + res[2].Split("\n")[0].Should().Be("Header A: Header A.B"); + res[2].Split("\n")[1].Should().Be("Text A.B"); + + res[3].Split("\n")[0].Should().Be("Header A: Header A.B: Header A.B.A"); + res[3].Split("\n")[1].Should().Be("Text A.B.A"); + + res[4].Split("\n")[0].Should().Be("Header A: Header A.B: Header A.B.B"); + res[4].Split("\n")[1].Should().Be("Text A.B.B"); + + res[5].Split("\n")[0].Should().Be("Header A: Header A.B: Header A.B.C"); + res[5].Split("\n")[1].Should().Be("Text A.B.C"); + + res[6].Split("\n")[0].Should().Be("Header A: Header A.C"); + res[6].Split("\n")[1].Should().Be("Text A.C"); + + res[7].Split("\n")[0].Should().Be("Header A: Header A.C: Header A.C.A"); + res[7].Split("\n")[1].Should().Be("Text A.C.A"); + + res[8].Split("\n")[0].Should().Be("Header A: Header A.C: Header A.C.B"); + res[8].Split("\n")[1].Should().Be("Text A.C.B"); + + res[9].Split("\n")[0].Should().Be("Header B"); + res[9].Split("\n")[1].Should().Be("Text B"); + + res[10].Split("\n")[0].Should().Be("Header B: Header B.A"); + res[10].Split("\n")[1].Should().Be("Text B.A"); + + res[11].Split("\n")[0].Should().Be("Header B: Header B.B"); + res[11].Split("\n")[1].Should().Be("Text B.B"); + + res[12].Split("\n")[0].Should().Be("Header B: Header B.B: Header B.B.A"); + res[12].Split("\n")[1].Should().Be("Text B.B.A"); + + res[13].Split("\n")[0].Should().Be("Header B: Header B.B: Header B.B.B"); + res[13].Split("\n")[1].Should().Be("Text B.B.B"); + + res[14].Split("\n")[0].Should().Be("Header B: Header B.C"); + res[14].Split("\n")[1].Should().Be("Text B.C"); + + res[15].Split("\n")[0].Should().Be("Header B: Header B.C: Header B.C.A"); + res[15].Split("\n")[1].Should().Be("Text B.C.A"); + + res[16].Split("\n")[0].Should().Be("Header B: Header B.C: Header B.C.B"); + res[16].Split("\n")[1].Should().Be("Text B.C.B"); + + res[17].Split("\n")[0].Should().Be("Header B: Header B.C: Header B.C.C"); + res[17].Split("\n")[1].Should().Be("Text B.C.C"); + } } \ No newline at end of file From 8b13a5e3c55348adbed7dfa510fc69575cbaf1e4 Mon Sep 17 00:00:00 2001 From: Danny Lathouwers Date: Tue, 5 Aug 2025 14:25:02 +0200 Subject: [PATCH 2/4] Added missing package references --- .../LangChain.Cli.IntegrationTests.csproj | 4 ++++ src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj | 4 ++++ src/Directory.Packages.props | 1 + .../LangChain.DocumentLoaders.IntegrationTests.csproj | 4 ++++ src/Meta/test/LangChain.IntegrationTests.csproj | 1 + .../test/LangChain.Splitters.Abstractions.Tests.csproj | 4 ++++ .../CSharp/test/LangChain.Splitters.CSharp.Tests.csproj | 4 ++++ .../test/LangChain.Utilities.Postgres.IntegrationTests.csproj | 1 + 8 files changed, 23 insertions(+) diff --git a/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj b/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj index dc237dbd..6f1943f4 100644 --- a/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj +++ b/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj @@ -7,6 +7,10 @@ enable + + + + diff --git a/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj b/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj index 35422a2e..2942cba7 100644 --- a/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj +++ b/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj @@ -4,6 +4,10 @@ net9.0 + + + + diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 9358d150..1ab22ceb 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -9,6 +9,7 @@ + all diff --git a/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj b/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj index d5e6c8c7..cacde49e 100644 --- a/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj +++ b/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj @@ -6,6 +6,10 @@ $(NoWarn) + + + + diff --git a/src/Meta/test/LangChain.IntegrationTests.csproj b/src/Meta/test/LangChain.IntegrationTests.csproj index 09d189ce..838985e9 100644 --- a/src/Meta/test/LangChain.IntegrationTests.csproj +++ b/src/Meta/test/LangChain.IntegrationTests.csproj @@ -6,6 +6,7 @@ + diff --git a/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj b/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj index 208c95a9..b351aa60 100644 --- a/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj +++ b/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj @@ -4,6 +4,10 @@ net9.0 + + + + diff --git a/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj b/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj index 9a8ca786..a544c7af 100644 --- a/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj +++ b/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj @@ -4,6 +4,10 @@ net9.0 + + + + diff --git a/src/Utilities/Postgres/test/LangChain.Utilities.Postgres.IntegrationTests.csproj b/src/Utilities/Postgres/test/LangChain.Utilities.Postgres.IntegrationTests.csproj index 5ab5ea0b..6e9dcfed 100644 --- a/src/Utilities/Postgres/test/LangChain.Utilities.Postgres.IntegrationTests.csproj +++ b/src/Utilities/Postgres/test/LangChain.Utilities.Postgres.IntegrationTests.csproj @@ -6,6 +6,7 @@ + From c0b91b9a2440325f8fff98a5d5a8c232e97dd135 Mon Sep 17 00:00:00 2001 From: "Konstantin S." Date: Sun, 30 Aug 2026 11:25:59 +0400 Subject: [PATCH 3/4] fix: integrate text splitter corrections on current main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preserve Danny Lathouwers’ line-ending and breadcrumb fixes while removing obsolete FluentAssertions package edits and adding focused depth coverage. Co-authored-by: Danny Lathouwers --- .../LangChain.Cli.IntegrationTests.csproj | 4 ---- .../test/UnitTests/LangChain.Core.UnitTests.csproj | 4 ---- src/Directory.Packages.props | 2 +- ...LangChain.DocumentLoaders.IntegrationTests.csproj | 4 ---- src/Meta/test/LangChain.IntegrationTests.csproj | 1 - .../Abstractions/src/Text/CharacterTextSplitter.cs | 4 ++-- .../src/Text/MarkdownHeaderTextSplitter.cs | 12 +++++------- .../src/Text/RecursiveCharacterTextSplitter.cs | 4 ++-- src/Splitters/Abstractions/src/Text/TextSplitter.cs | 8 +++++++- .../LangChain.Splitters.Abstractions.Tests.csproj | 4 ---- .../Abstractions/test/Tests.MarkdownHeader.cs | 12 +++++++++++- .../test/LangChain.Splitters.CSharp.Tests.csproj | 4 ---- 12 files changed, 28 insertions(+), 35 deletions(-) diff --git a/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj b/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj index 5a1eee83..1f441009 100644 --- a/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj +++ b/src/Cli/test/LangChain.Cli.IntegrationTests/LangChain.Cli.IntegrationTests.csproj @@ -7,10 +7,6 @@ enable - - - - diff --git a/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj b/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj index 06bd9ecd..52fcbee2 100644 --- a/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj +++ b/src/Core/test/UnitTests/LangChain.Core.UnitTests.csproj @@ -4,10 +4,6 @@ net10.0 - - - - diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 9f01b974..4dacde1c 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -71,4 +71,4 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + \ No newline at end of file diff --git a/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj b/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj index 5e876ef2..f6d149ce 100644 --- a/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj +++ b/src/DocumentLoaders/IntegrationTests/LangChain.DocumentLoaders.IntegrationTests.csproj @@ -6,10 +6,6 @@ $(NoWarn) - - - - diff --git a/src/Meta/test/LangChain.IntegrationTests.csproj b/src/Meta/test/LangChain.IntegrationTests.csproj index bc90e2a0..12144495 100644 --- a/src/Meta/test/LangChain.IntegrationTests.csproj +++ b/src/Meta/test/LangChain.IntegrationTests.csproj @@ -6,7 +6,6 @@ - diff --git a/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs b/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs index ec9e5b7d..5b9f2adf 100644 --- a/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/CharacterTextSplitter.cs @@ -15,7 +15,7 @@ public override IReadOnlyList SplitText(string text) { text = text ?? throw new ArgumentNullException(nameof(text)); - text = text.Replace("\r", ""); // some people are using windows + text = NormalizeLineEndings(text); List splits; if (separator != null) @@ -29,4 +29,4 @@ public override IReadOnlyList SplitText(string text) return this.MergeSplits(splits, separator ?? string.Empty); } -} \ No newline at end of file +} diff --git a/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs b/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs index 67390e2d..2b14048a 100644 --- a/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs @@ -35,9 +35,7 @@ public override IReadOnlyList SplitText(string text) text = text ?? throw new ArgumentNullException(nameof(text)); // Split the input text by newline character ("\n"). - var lines = text - .Replace("\r", "") // some people are using windows - .Split(separator, StringSplitOptions.None); + var lines = NormalizeLineEndings(text).Split(separator, StringSplitOptions.None); var content = new List(); @@ -74,10 +72,10 @@ public override IReadOnlyList SplitText(string text) { if (hLen <= currentHeaderLen) { - var existingHeader = currentHeader.Split('|'); - - string prevHeader = string.Join("|", existingHeader.Take(existingHeader.Length - (1 - hLen + currentHeaderLen))); - currentHeader = prevHeader + "|" + strippedLine.TrimStart('#').Trim(); + var parentHeaders = currentHeader + .Split('|', StringSplitOptions.RemoveEmptyEntries) + .Take(hLen - 1); + currentHeader = string.Join("|", parentHeaders.Append(strippedLine.TrimStart('#').Trim())); currentHeaderLen = hLen; continue; } diff --git a/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs b/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs index 85fcb75f..2e8163b8 100644 --- a/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/RecursiveCharacterTextSplitter.cs @@ -19,7 +19,7 @@ public override IReadOnlyList SplitText(string text) { text = text ?? throw new ArgumentNullException(nameof(text)); - text = text.Replace("\r", ""); // some people are using windows + text = NormalizeLineEndings(text); List finalChunks = new List(); string separator = _separators[_separators.Count - 1]; @@ -80,4 +80,4 @@ public override IReadOnlyList SplitText(string text) return finalChunks; } -} \ No newline at end of file +} diff --git a/src/Splitters/Abstractions/src/Text/TextSplitter.cs b/src/Splitters/Abstractions/src/Text/TextSplitter.cs index 97cbf6ab..c84a4d63 100644 --- a/src/Splitters/Abstractions/src/Text/TextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/TextSplitter.cs @@ -45,6 +45,12 @@ protected TextSplitter( /// protected int ChunkOverlap => _chunkOverlap; + /// + /// Normalizes Windows and legacy Mac line endings before separator-based splitting. + /// + internal static string NormalizeLineEndings(string text) => + text.Replace("\r\n", "\n", StringComparison.Ordinal).Replace('\r', '\n'); + /// /// /// @@ -125,4 +131,4 @@ protected IReadOnlyList MergeSplits(IEnumerable splits, string s // todo: Implement from_tiktoken_encoder -} \ No newline at end of file +} diff --git a/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj b/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj index 7638c029..ae24f32c 100644 --- a/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj +++ b/src/Splitters/Abstractions/test/LangChain.Splitters.Abstractions.Tests.csproj @@ -4,10 +4,6 @@ net10.0 - - - - diff --git a/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs b/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs index 603fd88d..6b66052c 100644 --- a/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs +++ b/src/Splitters/Abstractions/test/Tests.MarkdownHeader.cs @@ -126,4 +126,14 @@ public void TestMarkdown4() res[17].Split("\n")[0].Should().Be("Header B: Header B.C: Header B.C.C"); res[17].Split("\n")[1].Should().Be("Text B.C.C"); } -} \ No newline at end of file + + [Test] + public void HeaderDepthJump_RemovesEveryExitedBreadcrumb() + { + const string markdown = "# A\r\n## B\r\n### C\r\n# D\r\nText"; + + var result = new MarkdownHeaderTextSplitter().SplitText(markdown); + + result.Should().ContainSingle().Which.Should().Be("D\nText"); + } +} diff --git a/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj b/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj index 124e3a7e..d4aa4c4c 100644 --- a/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj +++ b/src/Splitters/CSharp/test/LangChain.Splitters.CSharp.Tests.csproj @@ -4,10 +4,6 @@ net10.0 - - - - From 86c330278dbe11d6b6294b59a19a330174ad6402 Mon Sep 17 00:00:00 2001 From: "Konstantin S." Date: Sun, 30 Aug 2026 11:27:14 +0400 Subject: [PATCH 4/4] fix: keep splitter changes compatible with legacy targets --- .../Abstractions/src/Text/MarkdownHeaderTextSplitter.cs | 7 +++++-- src/Splitters/Abstractions/src/Text/TextSplitter.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs b/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs index 2b14048a..a290724d 100644 --- a/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/MarkdownHeaderTextSplitter.cs @@ -16,6 +16,7 @@ private sealed class LineType private const string _codeBlockseparator = "```"; private readonly static string[] _defauldHeaders = { "#", "##", "###", "####", "#####", "######" }; private readonly static string[] separator = { "\n" }; + private static readonly char[] HeaderSeparator = { '|' }; /// public MarkdownHeaderTextSplitter( @@ -73,9 +74,11 @@ public override IReadOnlyList SplitText(string text) if (hLen <= currentHeaderLen) { var parentHeaders = currentHeader - .Split('|', StringSplitOptions.RemoveEmptyEntries) + .Split(HeaderSeparator, StringSplitOptions.RemoveEmptyEntries) .Take(hLen - 1); - currentHeader = string.Join("|", parentHeaders.Append(strippedLine.TrimStart('#').Trim())); + currentHeader = string.Join( + "|", + parentHeaders.Concat(new[] { strippedLine.TrimStart('#').Trim() })); currentHeaderLen = hLen; continue; } diff --git a/src/Splitters/Abstractions/src/Text/TextSplitter.cs b/src/Splitters/Abstractions/src/Text/TextSplitter.cs index c84a4d63..9eda5a68 100644 --- a/src/Splitters/Abstractions/src/Text/TextSplitter.cs +++ b/src/Splitters/Abstractions/src/Text/TextSplitter.cs @@ -49,7 +49,7 @@ protected TextSplitter( /// Normalizes Windows and legacy Mac line endings before separator-based splitting. /// internal static string NormalizeLineEndings(string text) => - text.Replace("\r\n", "\n", StringComparison.Ordinal).Replace('\r', '\n'); + text.Replace("\r\n", "\n").Replace('\r', '\n'); /// ///