예제 #1
0
        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)
            {
                content += renderer.Render(splitToken);
            }
            return(content);
        }
예제 #2
0
파일: DfmRenderer.cs 프로젝트: mairaw/docfx
        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)
                {
                    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.ToUpper();
                    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
                {
                    content += "<blockquote>";
                    foreach (var item in splitToken.InnerTokens)
                    {
                        content += renderer.Render(item);
                    }
                    content += "</blockquote>\n";
                }
            }
            return(content);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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);
        }