Files
chapter-organizer/Core/Parsers/EventOccurrence/LineClassifier.cs
T
poprhythm 19e5ef0675 Enhance event occurrence parsing to skip unmatched high school section headers
This commit introduces a new property to track skipped high school section headers in the EventOccurrenceParseResult and EventOccurrenceParserResult classes. The EventOccurrenceParser has been updated to gracefully skip HS section headers that do not match any event definitions, improving the parsing logic. Additionally, the LocationParsingConfiguration has been removed from the EventOccurrenceParser, simplifying its constructor. Unit tests have been updated to reflect these changes and ensure correct behavior during parsing.
2026-01-09 00:14:19 -05:00

46 lines
1.4 KiB
C#

namespace Core.Parsers.EventOccurrence;
/// <summary>
/// Classifies lines to determine if they should be skipped during parsing.
/// </summary>
public static class LineClassifier
{
/// <summary>
/// Checks if a line is empty or contains only whitespace.
/// </summary>
public static bool IsEmptyLine(string line)
{
return string.IsNullOrWhiteSpace(line);
}
/// <summary>
/// Checks if a line is a comment (starts with "#").
/// </summary>
public static bool IsCommentLine(string line)
{
return EventOccurrenceGrammar.IsCommentLine(line);
}
/// <summary>
/// Determines if a line is a continuation/wrapped line that should be skipped.
/// These are typically lines that:
/// - Start with "*" (marks the start of a continuation block)
/// - Are parenthetical notes like "(Semifinalists only)"
/// </summary>
public static bool IsContinuationLine(string line)
{
var trimmed = line.Trim();
// Check if line starts with "*" (marks continuation block start)
if (trimmed.StartsWith("*", StringComparison.Ordinal))
return true;
// Skip parenthetical notes
if (trimmed.StartsWith("(", StringComparison.Ordinal) && trimmed.EndsWith(")", StringComparison.Ordinal))
return true;
return false;
}
}