当前位置: 首页>>代码示例>>C#>>正文


C# IMarkdownRenderer类代码示例

本文整理汇总了C#中IMarkdownRenderer的典型用法代码示例。如果您正苦于以下问题:C# IMarkdownRenderer类的具体用法?C# IMarkdownRenderer怎么用?C# IMarkdownRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IMarkdownRenderer类属于命名空间,在下文中一共展示了IMarkdownRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

 public virtual StringBuffer Render(IMarkdownRenderer render, DfmYamlHeaderBlockToken token, MarkdownBlockContext context)
 {
     StringBuffer content = "---\n";
     content += token.Content;
     content += "\n---\n";
     return content;
 }
开发者ID:dotnet,项目名称:docfx,代码行数:7,代码来源:DfmMarkdownRenderer.cs

示例2: Render

        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            const string ListStartString = "* ";
            var content = StringBuffer.Empty;

            if (token.Ordered)
            {
                foreach (var t in token.Tokens)
                {
                    var listItemToken = t as MarkdownListItemBlockToken;
                    if (listItemToken == null)
                    {
                        throw new Exception($"token {t.GetType()} is not MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{t.RawMarkdown}");
                    }
                    content += ListStartString;
                    content += render.Render(t);
                }
            }
            else
            {
                for (int i = 1; i < token.Tokens.Length; ++i)
                {
                    var listItemToken = token.Tokens[i] as MarkdownListItemBlockToken;

                    if (listItemToken == null)
                    {
                        throw new Exception($"token {token.Tokens[i].GetType()} is not MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{token.Tokens[i].RawMarkdown}");
                    }

                    content += i.ToString();
                    content += ". ";
                }
            }
            return content;
        }
开发者ID:yodamaster,项目名称:docfx,代码行数:35,代码来源:MarkdownRenderer.cs

示例3: GenerateReferenceNotFoundErrorMessage

 public static string GenerateReferenceNotFoundErrorMessage(IMarkdownRenderer renderer, DfmFencesToken token)
 {
     var errorMessageInMarkdown = $"Can not find reference {token.Path}";
     var errorMessage = $"Unable to resolve {token.SourceInfo.Markdown}. {errorMessageInMarkdown}. at line {token.SourceInfo.LineNumber}.";
     Logger.LogError(errorMessage);
     return GetRenderedFencesBlockString(token, renderer.Options, errorMessageInMarkdown);
 }
开发者ID:dotnet,项目名称:docfx,代码行数:7,代码来源:DfmFencesBlockHelper.cs

示例4: Render

        public virtual StringBuffer Render(IMarkdownRenderer render, AzureVideoBlockToken token, MarkdownBlockContext context)
        {
            StringBuffer content = StringBuffer.Empty;

            object path;
            if (!context.Variables.TryGetValue("path", out path))
            {
                path = string.Empty;
                content += token.SourceInfo.Markdown;
                return content += "\n\n";
            }

            if (!context.Variables.ContainsKey("azureVideoInfoMapping"))
            {
                Logger.LogWarning($"Can't fild azure video info mapping. Raw: {token.SourceInfo.Markdown}");
                content = token.SourceInfo.Markdown;
                return content + "\n\n";
            }

            var azureVideoInfoMapping = (IReadOnlyDictionary<string, AzureVideoInfo>)context.Variables["azureVideoInfoMapping"];
            if (azureVideoInfoMapping == null || !azureVideoInfoMapping.ContainsKey(token.VideoId))
            {
                Logger.LogWarning($"Can't fild azure video info mapping for file {path}. Raw: {token.SourceInfo.Markdown}");
                content = token.SourceInfo.Markdown;
                return content + "\n\n";
            }

            var azureVideoInfo = azureVideoInfoMapping[token.VideoId];
            content += [email protected]"<iframe width=""{azureVideoInfo.Width}"" height=""{azureVideoInfo.Height}"" src=""{azureVideoInfo.Link}"" frameborder=""0"" allowfullscreen=""true""></iframe>";
            return content + "\n\n";
        }
开发者ID:vicancy,项目名称:docfx,代码行数:31,代码来源:AzureMarkdownRenderer.cs

示例5: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmIncludeInlineToken token, MarkdownInlineContext context)
 {
     lock (_inlineInclusionHelper)
     {
         return _inlineInclusionHelper.Load(renderer, token.Src, token.Raw, token.SourceInfo, context, (DfmEngine)renderer.Engine);
     }
 }
开发者ID:dotnet,项目名称:docfx,代码行数:7,代码来源:DfmRenderer.cs

示例6: Render

 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;
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:27,代码来源:DfmRenderer.cs

示例7: Render

        public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownCodeBlockToken token, MarkdownBlockContext context)
        {
            bool escaped = false;
            string code = token.Code;
            if (engine.Options.Highlight != null)
            {
                var highlightCode = engine.Options.Highlight(code, token.Lang);
                if (highlightCode != null && highlightCode != code)
                {
                    escaped = true;
                    code = highlightCode;
                }
            }

            if (string.IsNullOrEmpty(token.Lang))
            {
                return (StringBuffer)"<pre><code>" + (escaped ? code : StringHelper.Escape(code, true)) + "\n</code></pre>";
            }

            return "<pre><code class=\""
                + engine.Options.LangPrefix
                + StringHelper.Escape(token.Lang, true)
                + "\">"
                + (escaped ? code : StringHelper.Escape(code, true))
                + "\n</code></pre>\n";
        }
开发者ID:yodamaster,项目名称:docfx,代码行数:26,代码来源:HtmlRenderer.cs

示例8: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmIncludeBlockToken token, MarkdownBlockContext context)
 {
     var href = token.Src == null ? null : $"src=\"{StringHelper.HtmlEncode(token.Src)}\"";
     var name = token.Name == null ? null : StringHelper.HtmlEncode(token.Name);
     var title = token.Title == null ? null : $"title=\"{StringHelper.HtmlEncode(token.Title)}\"";
     var resolved = _blockInclusionHelper.Load(renderer, token.Src, token.Raw, context, ((DfmEngine)renderer.Engine).InternalMarkup);
     return resolved;
 }
开发者ID:xier2012,项目名称:docfx,代码行数:8,代码来源:DfmRenderer.cs

示例9: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownParagraphBlockToken token, MarkdownBlockContext context)
 {
     var childContent = StringBuffer.Empty;
     foreach (var item in token.InlineTokens.Tokens)
     {
         childContent += renderer.Render(item);
     }
     return Insert(token, ExposeTokenName(token), childContent);
 }
开发者ID:dotnet,项目名称:docfx,代码行数:9,代码来源:JsonTokenTreeRenderer.cs

示例10: RenderAzureIncludeToken

 private StringBuffer RenderAzureIncludeToken(IMarkdownRenderer render, AzureIncludeBasicToken token, IMarkdownContext context)
 {
     StringBuffer content = StringBuffer.Empty;
     foreach(var t in token.Tokens)
     {
         content += render.Render(t);
     }
     return content;
 }
开发者ID:vicancy,项目名称:docfx,代码行数:9,代码来源:AzureMarkdownRenderer.cs

示例11: Render

 public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownHtmlBlockToken token, MarkdownBlockContext context)
 {
     StringBuffer content = StringBuffer.Empty;
     foreach(var t in token.Content.Tokens)
     {
         content += render.Render(t);
     }
     return content;
 }
开发者ID:ansyral,项目名称:docfx,代码行数:9,代码来源:MarkdownRenderer.cs

示例12: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmXrefInlineToken token, MarkdownInlineContext context)
 {
     var childContent = StringBuffer.Empty;
     foreach (var item in token.Content)
     {
         childContent += renderer.Render(item);
     }
     return Insert(token, $"{ExposeTokenNameInDfm(token)}>{Escape(token.Href)}", childContent);
 }
开发者ID:dotnet,项目名称:docfx,代码行数:9,代码来源:DfmJsonTokenTreeRender.cs

示例13: LoadCore

        private string LoadCore(IMarkdownRenderer adapter, string currentPath, string raw, SourceInfo sourceInfo, IMarkdownContext context, DfmEngine engine)
        {
            try
            {
                if (!PathUtility.IsRelativePath(currentPath))
                {
                    return GenerateErrorNodeWithCommentWrapper("INCLUDE", $"Absolute path \"{currentPath}\" is not supported.", raw, sourceInfo);
                }

                // Always report original include file dependency
                var originalRelativePath = currentPath;
                context.ReportDependency(currentPath);

                var parents = context.GetFilePathStack();
                string parent = string.Empty;
                if (parents == null) parents = ImmutableStack<string>.Empty;

                // Update currentPath to be referencing to sourcePath
                else if (!parents.IsEmpty)
                {
                    parent = parents.Peek();
                    currentPath = ((RelativePath)currentPath).BasedOn((RelativePath)parent);
                }

                if (parents.Contains(currentPath, FilePathComparer.OSPlatformSensitiveComparer))
                {
                    return GenerateErrorNodeWithCommentWrapper("INCLUDE", $"Unable to resolve {raw}: Circular dependency found in \"{parent}\"", raw, sourceInfo);
                }

                // Add current file path to chain when entering recursion
                parents = parents.Push(currentPath);
                string result;
                HashSet<string> dependency;
                if (!_dependencyCache.TryGetValue(currentPath, out dependency) ||
                    !_cache.TryGet(currentPath, out result))
                {
                    var filePathWithStatus = DfmFallbackHelper.GetFilePathWithFallback(originalRelativePath, context);
                    var src = File.ReadAllText(filePathWithStatus.Item1);
                    dependency = new HashSet<string>();
                    src = engine.InternalMarkup(src, context.SetFilePathStack(parents).SetDependency(dependency).SetIsInclude());

                    result = UpdateToHrefFromWorkingFolder(src, currentPath);
                    result = GenerateNodeWithCommentWrapper("INCLUDE", $"Include content from \"{currentPath}\"", result);
                    _cache.Add(currentPath, result);
                    _dependencyCache[currentPath] = dependency;
                }
                context.ReportDependency(
                    from d in dependency
                    select (string)((RelativePath)currentPath + (RelativePath)d - (RelativePath)parent));
                return result;
            }
            catch (Exception e)
            {
                return GenerateErrorNodeWithCommentWrapper("INCLUDE", $"Unable to resolve {raw}:{e.Message}", raw, sourceInfo);
            }
        }
开发者ID:vicancy,项目名称:docfx,代码行数:56,代码来源:DocfxFlavoredIncHelper.cs

示例14: Render

 public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownImageInlineToken token, MarkdownInlineContext context)
 {
     switch(token.LinkType)
     {
         case MarkdownLinkType.NormalLink:
             return RenderImageNormalLink(render, token, context);
         case MarkdownLinkType.NumberLink:
             return RenderNumberLink(render, token, context);
         case MarkdownLinkType.RefLink:
             return RenderRefLink(render, token, context);
         default:
             throw new NotSupportedException($"Link type: {token.LinkType} doesn't support in Image Link Render");
     }
 }
开发者ID:dotnet,项目名称:docfx,代码行数:14,代码来源:MarkdownRenderer.cs

示例15: RenderImageNormalLink

 private StringBuffer RenderImageNormalLink(IMarkdownRenderer render, MarkdownImageInlineToken token, MarkdownInlineContext context)
 {
     StringBuffer content = StringBuffer.Empty;
     content += "![";
     content += token.Text;
     content += "](";
     content += Regexes.Helper.MarkdownUnescape.Replace(token.Href, m => "\\" + m.Value);
     if (!string.IsNullOrEmpty(token.Title))
     {
         content += " \"";
         content += Regexes.Helper.MarkdownUnescape.Replace(token.Title, m => "\\" + m.Value);
         content += "\"";
     }
     content += ")";
     return content;
 }
开发者ID:dotnet,项目名称:docfx,代码行数:16,代码来源:MarkdownRenderer.cs


注:本文中的IMarkdownRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。