예제 #1
0
        private static int GetHRCount(string markdownText, int start, int end, out int actulEnd)
        {
            actulEnd = start;
            char hrChar      = '\0';
            int  hrCharCount = 0;
            int  pos         = start;

            while (pos < end)
            {
                char c = markdownText[pos++];
                if (c == '*' || c == '-' || c == '_')
                {
                    if (hrCharCount > 0 && c != hrChar)
                    {
                        return(-1);
                    }
                    hrChar = c;
                    hrCharCount++;
                }
                else if (c == '\n')
                {
                    break;
                }
                else if (!ParseBlocksHelper.IsWhiteSpace(c))
                {
                    return(-1);
                }
            }
            actulEnd = pos;
            return(hrCharCount);
        }
예제 #2
0
 internal static ParagraphBlock Parse(string markdownText, int start, int end, out int actualEnd)
 {
     if (start > end)
     {
         actualEnd = start;
         return(null);
     }
     actualEnd = ParseBlocksHelper.FindLineEnd(markdownText, start, end);
     return(new ParagraphBlock
     {
         Inlines = Common.ParseInlines(markdownText, start, actualEnd),
     });
 }
예제 #3
0
        internal static ListElement Parse(string markdownText, int start, int end, out int actualEnd)
        {
            actualEnd = start;
            int contentStartPos = GetContentStartPos(markdownText, start, end, out ListStyle style);

            if (contentStartPos == start)
            {
                return(null);
            }
            actualEnd = ParseBlocksHelper.FindLineEnd(markdownText, contentStartPos, end);
            return(actualEnd > start ?
                   new ListElement
            {
                Inlines = Common.ParseInlines(markdownText, contentStartPos, actualEnd),
                Style = style,
            } : null);
        }
예제 #4
0
        internal static HeaderBlock Parse(string markdownText, int start, int end, out int actualEnd)
        {
            int headerLevel = GetHeaderLevel(markdownText, start, end, out int textStart);

            if (headerLevel == 0 ||
                textStart > end ||
                markdownText[textStart] == '\r' ||
                markdownText[textStart] == '\n')
            {
                actualEnd = start;
                return(null);
            }
            actualEnd = ParseBlocksHelper.FindLineEnd(markdownText, textStart, end);
            return(new HeaderBlock
            {
                HeaderLevel = headerLevel,
                Inlines = Common.ParseInlines(markdownText, textStart, actualEnd),
            });
        }