internal static HorizontalRuleBlock Parse(string markdown, int start, int end)
{
// A horizontal rule is a line with at least 3 stars, optionally separated by spaces
// OR a line with at least 3 dashes, optionally separated by spaces
// OR a line with at least 3 underscores, optionally separated by spaces.
char hrChar = '\0';
int hrCharCount = 0;
int pos = start;
while (pos < end)
{
char c = markdown[pos++];
if (c == '*' || c == '-' || c == '_')
{
// All of the non-whitespace characters on the line must match.
if (hrCharCount > 0 && c != hrChar)
return null;
hrChar = c;
hrCharCount++;
}
else if (c == '\n')
break;
else if (!Common.IsWhiteSpace(c))
return null;
}
// Hopefully there were at least 3 stars/dashes/underscores.
return hrCharCount >= 3 ? new HorizontalRuleBlock() : null;
}