Skip to content

Commit

Permalink
fix: Update MarkdownHeaderTextSplitter.cs (#485)
Browse files Browse the repository at this point in the history
This change prevents errors when the markdown file includes lines that start with # but have no following characters.

Co-authored-by: Konstantin S. <[email protected]>
  • Loading branch information
mzand111 and HavenDV authored Dec 10, 2024
1 parent 12de181 commit 0859f8d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ private bool IsHeader(string line, out int len)
len = 0;
foreach (var header in _headersToSplitOn)
{
if (line.Length <= header.Length + 1)
return false;//Empty lines starting with #s should not be considered as headers. Removing this line would result in exceptions in that conditions
if (line.Trim().StartsWith(header, StringComparison.Ordinal) && line[header.Length] == ' ')
{
len = header.Length;
Expand All @@ -131,4 +133,4 @@ private bool IsHeader(string line, out int len)

return false;
}
}
}

0 comments on commit 0859f8d

Please sign in to comment.