private static void AggregateCore( MarkdownHeadingBlockToken headToken, IMarkdownTokenAggregateContext context, int offset, List <DfmTabItemBlockToken> items, IMarkdownToken terminator) { var md = items.Aggregate(StringBuffer.Empty, (s, t) => s + t.SourceInfo.Markdown); if (terminator != null) { md += terminator.SourceInfo.Markdown; offset++; } var groupId = HashUtility.GetSha256HashString(items[0].SourceInfo.File ?? string.Empty).Replace("/", "-").Remove(10); context.AggregateTo( new DfmTabGroupBlockToken( DfmTabGroupBlockRule.Instance, headToken.Context, groupId, items.ToImmutableArray(), 0, headToken.SourceInfo.Copy(md.ToString())), offset); }
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); }
protected override bool AggregateCore(MarkdownHeadingBlockToken headToken, IMarkdownTokenAggregateContext context) { var info = ParseHeading(headToken); if (info == null) { return(false); } context.AggregateTo( new MarkdownHeadingBlockToken( headToken.Rule, headToken.Context, new InlineContent(headToken.Content.Tokens.RemoveRange(0, 2)), info, headToken.Depth, headToken.SourceInfo), 1); return(true); }
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); }
private static void AggregateCore( MarkdownHeadingBlockToken headToken, IMarkdownTokenAggregateContext context, int offset, List <DfmTabItemBlockToken> items, IMarkdownToken terminator) { var md = items.Aggregate(StringBuffer.Empty, (s, t) => s + t.SourceInfo.Markdown); if (terminator != null) { md += terminator.SourceInfo.Markdown; offset++; } context.AggregateTo( new DfmTabGroupBlockToken( DfmTabGroupBlockRule.Instance, headToken.Context, Guid.NewGuid().ToString(), items.ToImmutableArray(), 0, headToken.SourceInfo.Copy(md.ToString())), offset); }