Skip to content

Commit

Permalink
Update MarkdownHeaderTextSplitter.cs
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.
  • Loading branch information
mzand111 authored Dec 10, 2024
1 parent 7151734 commit 6edac45
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 6edac45

Please sign in to comment.