Пример #1
0
            protected override bool AggregateCore(MarkdownParagraphBlockToken headToken, IMarkdownTokenAggregateContext context)
            {
                var tokenCount = 1;
                var next       = context.LookAhead(tokenCount);

                while (next is MarkdownNewLineBlockToken)
                {
                    tokenCount++;
                    next = context.LookAhead(tokenCount);
                }

                if (next is MarkdownParagraphBlockToken nextPara)
                {
                    context.AggregateTo(
                        new MarkdownParagraphBlockToken(
                            headToken.Rule,
                            headToken.Context,
                            new InlineContent(
                                headToken.InlineTokens.Tokens
                                .Add(new MarkdownBrInlineToken(headToken.Rule, headToken.InlineTokens.Tokens[0].Context, headToken.SourceInfo))
                                .AddRange(nextPara.InlineTokens.Tokens)),
                            headToken.SourceInfo),
                        tokenCount + 1);
                    return(true);
                }
                return(false);
            }
Пример #2
0
        protected override bool AggregateCore(MarkdownHeadingBlockToken headToken, IMarkdownTokenAggregateContext context)
        {
            var info = ParseHeading(headToken);

            if (info == null)
            {
                return(false);
            }
            int            offset     = 1;
            var            items      = new List <DfmTabItemBlockToken>();
            IMarkdownToken terminator = null;

            while (true)
            {
                var token = context.LookAhead(offset);
                switch (token)
                {
                case MarkdownHeadingBlockToken head:
                    var temp = ParseHeading(head);
                    if (temp == null)
                    {
                        goto default;
                    }
                    items.Add(CreateTabItem(info));
                    info = temp;
                    break;

                case MarkdownHrBlockToken hr:
                    terminator = hr;
                    goto case null;

                case null:
                    items.Add(CreateTabItem(info));
                    AggregateCore(headToken, context, offset, items, terminator);
                    return(true);

                default:
                    info.Content.Add(token);
                    break;
                }
                offset++;
            }
        }
Пример #3
0
 protected override bool AggregateCore(MarkdownHeadingBlockToken headToken, IMarkdownTokenAggregateContext context)
 {
     if (headToken.Depth == 1)
     {
         var next = context.LookAhead(1);
         if (next is MarkdownHrBlockToken)
         {
             context.AggregateTo(
                 new MarkdownHeadingBlockToken(
                     headToken.Rule,
                     headToken.Context,
                     headToken.Content,
                     headToken.Id,
                     2,
                     headToken.SourceInfo), 2);
             return(true);
         }
     }
     return(false);
 }