Update EventOccurrence parsing to use EventOccurrenceParseGroup for improved data structure

This commit refactors the EventOccurrence parsing logic to utilize the EventOccurrenceParseGroup class, enhancing the organization of parsed occurrences by grouping them based on event definitions and optional section levels. The changes include updates to the EventOccurrenceParseResult, EventOccurrenceParser, and EventOccurrenceParserService to accommodate the new grouping structure. Additionally, tests are modified to reflect these changes, ensuring that the parsing functionality remains intact and accurate. This refactor improves data handling and aligns with the overall architecture of the application.
This commit is contained in:
2026-04-04 21:55:44 -04:00
parent 4dcd9e5aab
commit f400813667
39 changed files with 1896 additions and 93 deletions
@@ -0,0 +1,44 @@
using System.Text;
namespace GoogleSheetsScheduleImport;
/// <summary>
/// Google Sheets cells can contain line breaks as LF/CR or Unicode line/paragraph separators.
/// Import text must be one logical line per occurrence.
/// </summary>
public static class TextNormalization
{
public static string ForSheetCell(string? raw)
{
if (string.IsNullOrWhiteSpace(raw))
return string.Empty;
return CollapseWhitespace(Core.Utility.TextUtil.SanitizeInput(raw.Trim()));
}
public static string ForEmitLine(string? raw)
{
if (string.IsNullOrWhiteSpace(raw))
return string.Empty;
return CollapseWhitespace(Core.Utility.TextUtil.SanitizeInput(raw.Trim()));
}
private static string CollapseWhitespace(string s)
{
var sb = new StringBuilder(s.Length);
var pendingSpace = false;
foreach (var ch in s)
{
if (char.IsWhiteSpace(ch))
pendingSpace = true;
else
{
if (pendingSpace && sb.Length > 0)
sb.Append(' ');
pendingSpace = false;
sb.Append(ch);
}
}
return sb.ToString().Trim();
}
}