コード例 #1
0
        /// <summary>
        /// Checks that hyperlink will be finished at some point.
        /// </summary>
        /// <param name="position">Position after "](" symbols</param>
        /// <returns></returns>
        private static bool IsHyperlinkSecondPart(string markdown, int position)
        {
            var builder = new StringBuilder();
            var endRepr = new HyperlinkTagInfo(TagPosition.Closing, LINK_PART).GetRepresentation();

            for (var i = position; i <= markdown.Length - endRepr.Length; ++i)
            {
                if (markdown.Substring(i, endRepr.Length) == endRepr)
                {
                    return(MarkdownParsingUtils.IsCorrectLink(builder.ToString()));
                }
                else
                {
                    builder.Append(markdown[i]);
                }
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// Checks that hyperlink will be finished at some point.
        /// </summary>
        /// <param name="position">Position after '[' symbol</param>
        /// <returns></returns>
        private static bool IsHyperlinkStart(string markdown, int position)
        {
            var closingValuePart = new HyperlinkTagInfo(TagPosition.Closing, VALUE_PART);
            var closingRepr      = closingValuePart.GetRepresentation();

            for (var i = position; i <= markdown.Length - closingRepr.Length; ++i)
            {
                if (markdown.Substring(i, closingRepr.Length) == closingRepr)
                {
                    var openingSecondPartRepr = Representation[closingValuePart.GetOfNextType().TagType];
                    if (i + openingSecondPartRepr.Length >= markdown.Length ||
                        markdown.Substring(i + 1, openingSecondPartRepr.Length) != openingSecondPartRepr)
                    {
                        return(false);
                    }
                    return(IsHyperlinkSecondPart(markdown, i + closingRepr.Length + openingSecondPartRepr.Length));
                }
            }
            return(false);
        }