PlotDirector/PlotLine/Services/StoryIntelligenceParagraphs.cs
2026-07-04 22:32:59 +01:00

34 lines
957 B
C#

using System.Text;
namespace PlotLine.Services;
public static class StoryIntelligenceParagraphs
{
public static IReadOnlyList<string> Split(string? chapterText)
=> (chapterText ?? string.Empty)
.Split(["\r\n\r\n", "\n\n", "\r\r"], StringSplitOptions.RemoveEmptyEntries)
.Select(paragraph => paragraph.Trim())
.Where(paragraph => !string.IsNullOrWhiteSpace(paragraph))
.ToList();
public static string Number(IReadOnlyList<string> paragraphs)
{
var builder = new StringBuilder();
for (var index = 0; index < paragraphs.Count; index++)
{
if (index > 0)
{
builder.AppendLine();
builder.AppendLine();
}
builder.Append('[')
.Append(index + 1)
.Append("] ")
.Append(paragraphs[index]);
}
return builder.ToString();
}
}