UniversalMarkdown.Parse.Elements.HorizontalRuleBlock.Parse C# (CSharp) Méthode

Parse() static private méthode

Parses a horizontal rule.
static private Parse ( string markdown, int start, int end ) : HorizontalRuleBlock
markdown string The markdown text.
start int The location of the start of the line.
end int The location of the end of the line.
Résultat HorizontalRuleBlock
        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;
        }