Esempio n. 1
0
        /// <summary>
        /// Parsing helper method.
        /// </summary>
        private static void AppendTextToListItem(ListItemBlock listItem, string markdown, int start, int end)
        {
            ListItemBuilder listItemBuilder = null;

            if (listItem.Blocks.Count > 0)
            {
                listItemBuilder = listItem.Blocks[listItem.Blocks.Count - 1] as ListItemBuilder;
            }

            if (listItemBuilder == null)
            {
                // Add a new block.
                listItemBuilder = new ListItemBuilder();
                listItem.Blocks.Add(listItemBuilder);
            }

            var builder = listItemBuilder.Builder;

            if (builder.Length >= 2 &&
                Common.IsWhiteSpace(builder[builder.Length - 2]) &&
                Common.IsWhiteSpace(builder[builder.Length - 1]))
            {
                builder.Length -= 2;
                builder.AppendLine();
            }
            else if (builder.Length > 0)
            {
                builder.Append(' ');
            }

            builder.Append(markdown.Substring(start, end - start));
        }
Esempio n. 2
0
        /// <summary>
        /// 获取标签生成器
        /// </summary>
        protected override TagBuilder GetTagBuilder()
        {
            var builder = new ListItemBuilder();

            Config(builder);
            return(builder);
        }
Esempio n. 3
0
        /// <summary>
        /// Parsing helper method.
        /// </summary>
        /// <param name="listItem"></param>
        /// <param name="markdown"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        private static bool AppendTextToListItem(ListItemBlock listItem, string markdown, int start, int end)
        {
            ListItemBuilder listItemBuilder = null;

            if (listItem.Blocks.Count > 0)
            {
                listItemBuilder = listItem.Blocks[listItem.Blocks.Count - 1] as ListItemBuilder;
            }
            if (listItemBuilder == null)
            {
                // Add a new block.
                listItemBuilder = new ListItemBuilder();
                listItem.Blocks.Add(listItemBuilder);
            }
            var builder = listItemBuilder.Builder;

            if (builder.Length >= 2 &&
                Common.IsWhiteSpace(builder[builder.Length - 2]) &&
                Common.IsWhiteSpace(builder[builder.Length - 1]))
            {
                builder.Length -= 2;
                builder.AppendLine();
            }
            else if (builder.Length > 0)
            {
                builder.Append(' ');
            }
            var  str     = markdown.Substring(start, end - start);
            bool codeTag = false;

            if (str.StartsWith("```"))
            {
                builder.AppendLine();
                codeTag = true;
            }
            builder.AppendLine(str);
            return(codeTag);
        }
 /// <summary>
 /// Parsing helper method.
 /// </summary>
 /// <param name="listItem"></param>
 /// <param name="markdown"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 private static void AppendTextToListItem(ListItemBlock listItem, string markdown, int start, int end)
 {
     ListItemBuilder listItemBuilder = null;
     if (listItem.Blocks.Count > 0)
         listItemBuilder = listItem.Blocks[listItem.Blocks.Count - 1] as ListItemBuilder;
     if (listItemBuilder == null)
     {
         // Add a new block.
         listItemBuilder = new ListItemBuilder();
         listItem.Blocks.Add(listItemBuilder);
     }
     var builder = listItemBuilder.Builder;
     if (builder.Length >= 2 &&
         Common.IsWhiteSpace(builder[builder.Length - 2]) &&
         Common.IsWhiteSpace(builder[builder.Length - 1]))
     {
         builder.Length -= 2;
         builder.AppendLine();
     }
     else if (builder.Length > 0)
         builder.Append(' ');
     builder.Append(markdown.Substring(start, end - start));
 }