public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { const string BlockQuoteStartString = "> "; const string BlockQuoteJoinString = "\n" + BlockQuoteStartString; var content = StringBuffer.Empty; foreach (var t in token.Tokens) { content += render.Render(t); } var contents = content.ToString().Split('\n'); content = StringBuffer.Empty; foreach (var item in contents) { if (content == StringBuffer.Empty) { content += BlockQuoteStartString; content += item; } else { content += BlockQuoteJoinString; content += item; } } return content; }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { const string BlockQuoteStartString = "> "; const string BlockQuoteJoinString = "\n" + BlockQuoteStartString; var content = StringBuffer.Empty; foreach (var t in token.Tokens) { content += render.Render(t); } var contents = content.ToString().Split('\n'); content = StringBuffer.Empty; foreach (var item in contents) { if (content == StringBuffer.Empty) { content += BlockQuoteStartString; content += item; } else { content += BlockQuoteJoinString; content += item; } } return(content + "\n\n"); }
public override StringBuffer Render(IMarkdownRenderer engine, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = string.Empty; var splitTokens = DfmRendererHelper.SplitBlockquoteTokens(token.Tokens); foreach (var splitToken in splitTokens) { if (splitToken.Token is DfmSectionBlockToken) { var sectionToken = splitToken.Token as DfmSectionBlockToken; content += $"<div{sectionToken.Attributes}>"; content += RenderTokens(engine, splitToken.InnerTokens.ToImmutableArray(), context, true, token.Rule); content += "</div>\n"; } else if (splitToken.Token is DfmNoteBlockToken) { var noteToken = splitToken.Token as DfmNoteBlockToken; content += $"<div class=\"{noteToken.NoteType}\"><h5>{noteToken.NoteType}</h5>" + RenderTokens(engine, splitToken.InnerTokens.ToImmutableArray(), context, true, token.Rule) + "</div>\n"; } else { content += "<blockquote>"; content += RenderTokens(engine, splitToken.InnerTokens.ToImmutableArray(), context, true, token.Rule); content += "</blockquote>\n"; } } return content; }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = "<blockquote>\n"; content += RenderTokens(engine, token.Tokens, context, true, token.Rule); return(content + "</blockquote>\n"); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = "<blockquote>\n"; foreach (var item in token.Tokens) { content += renderer.Render(item); } return content + "</blockquote>\n"; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = "<blockquote>\n"; foreach (var item in token.Tokens) { content += renderer.Render(item); } return(content + "</blockquote>\n"); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { var childContent = StringBuffer.Empty; foreach (var item in token.Tokens) { childContent += renderer.Render(item); } return(Insert(token, ExposeTokenName(token), childContent)); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { var childContent = StringBuffer.Empty; foreach (var item in token.Tokens) { childContent += renderer.Render(item); } return(this.Insert("Blockquote", childContent, Type.NonLeaf)); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer result = "<blockquote"; result = AppendSourceInfo(result, renderer, token); result += ">\n"; foreach (var item in token.Tokens) { result += renderer.Render(item); } return(result + "</blockquote>\n"); }
public override StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = string.Empty; var splitTokens = DfmRendererHelper.SplitBlockquoteTokens(token.Tokens); foreach (var splitToken in splitTokens) { if (splitToken.Token is DfmSectionBlockToken) { content += "<div"; content += ((DfmSectionBlockToken)splitToken.Token).Attributes; content += ">"; foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } content += "</div>\n"; } else if (splitToken.Token is DfmNoteBlockToken) { var noteToken = (DfmNoteBlockToken)splitToken.Token; content += "<div class=\""; content += noteToken.NoteType; content += "\"><h5>"; content += noteToken.NoteType; content += "</h5>"; foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } content += "</div>\n"; } else { content += "<blockquote>"; foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } content += "</blockquote>\n"; } } return content; }
public override StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = StringBuffer.Empty; var splitTokens = DfmBlockquoteHelper.SplitBlockquoteTokens(token.Tokens); foreach (var splitToken in splitTokens) { var sectionToken = splitToken.Token as DfmSectionBlockToken; if (sectionToken != null) { content += Insert(sectionToken, ExposeTokenNameInDfm(sectionToken)); foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } continue; } var noteToken = splitToken.Token as DfmNoteBlockToken; if (noteToken != null) { var type = noteToken.NoteType.ToUpper(); content += Insert(noteToken, type); foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } continue; } var videoToken = splitToken.Token as DfmVideoBlockToken; if (videoToken != null) { content += Insert(videoToken, $"{ExposeTokenNameInDfm(videoToken)}>{videoToken.Link}"); continue; } foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } } return Insert(token, ExposeTokenNameInDfm(token), content); }
public override StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = string.Empty; var splitTokens = DfmBlockquoteHelper.SplitBlockquoteTokens(token.Tokens); foreach (var splitToken in splitTokens) { if (splitToken.Token is DfmSectionBlockToken) { if (!splitToken.Token.SourceInfo.Markdown.EndsWith("\n")) { Logger.LogWarning("The content part of [!div] syntax is suggested to start in a new line.", file: splitToken.Token.SourceInfo.File, line: splitToken.Token.SourceInfo.LineNumber.ToString()); } content += "<div"; content += ((DfmSectionBlockToken)splitToken.Token).Attributes; content = AppendSourceInfo(content, renderer, splitToken.Token); content += ">"; foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } content += "</div>\n"; } else if (splitToken.Token is DfmNoteBlockToken) { if (!splitToken.Token.SourceInfo.Markdown.EndsWith("\n")) { Logger.LogWarning("The content part of NOTE/WARNING/CAUTION/IMPORTANT syntax is suggested to start in a new line.", file: splitToken.Token.SourceInfo.File, line: splitToken.Token.SourceInfo.LineNumber.ToString()); } var noteToken = (DfmNoteBlockToken)splitToken.Token; content += "<div class=\""; content += noteToken.NoteType.ToUpper(); content += "\""; content = AppendSourceInfo(content, renderer, splitToken.Token); content += ">"; string heading; if (Tokens != null && Tokens.TryGetValue(noteToken.NoteType.ToLower(), out heading)) { content += heading; } else { content += "<h5>"; content += noteToken.NoteType.ToUpper(); content += "</h5>"; } foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } content += "</div>\n"; } else if (splitToken.Token is DfmVideoBlockToken) { var videoToken = splitToken.Token as DfmVideoBlockToken; content += "<div class=\"embeddedvideo\"><iframe src=\""; content += videoToken.Link; content += "\" frameborder=\"0\" allowfullscreen=\"true\""; content = AppendSourceInfo(content, renderer, splitToken.Token); content += "></iframe></div>\n"; continue; } else { content += "<blockquote"; content = AppendSourceInfo(content, renderer, splitToken.Token); content += ">"; foreach (var item in splitToken.InnerTokens) { content += renderer.Render(item); } content += "</blockquote>\n"; } } return content; }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context) { StringBuffer content = "<blockquote>\n"; content += RenderTokens(engine, token.Tokens, context, true, token.Rule); return content + "</blockquote>\n"; }