using System.Text; namespace PlotLine.Services; public static class StoryIntelligenceParagraphs { public static IReadOnlyList 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 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(); } }