コード例 #1
0
        /// <summary>
        /// Transforms the raw markdown content into html
        /// </summary>
        private string Transform(string content)
        {
            var    githubMarkdown = new Octokit.MiscellaneousClient(new Octokit.Connection(new Octokit.ProductHeaderValue("NuGet.Docs")));
            string fileContents   = null;

            try
            {
                // Try to transform the content using GitHub's API
                var request = githubMarkdown.RenderRawMarkdown(content);
                request.Wait();

                if (request.IsCompleted)
                {
                    fileContents   = request.Result;
                    Page.Generator = "GitHub";
                }
            }
            catch
            {
                // If the call to GitHub failed, then we'll swallow the exception
                // and in the finally block, we'll use MarkdownSharp as a fallback.
            }
            finally
            {
                if (fileContents == null)
                {
                    fileContents   = new Markdown().Transform(content);
                    Page.Generator = "MarkdownSharp";
                }
            }

            return(ProcessTableOfContents(fileContents));
        }
コード例 #2
0
        /// <summary>
        /// Transforms the raw markdown content into html
        /// </summary>
        private string Transform(string content)
        {
            var    githubMarkdown = new Octokit.MiscellaneousClient(new Octokit.Connection(new Octokit.ProductHeaderValue("NuGet.Docs")));
            string fileContents   = null;

            if (fileContents == null)
            {
                fileContents   = new Markdown().Transform(content);
                Page.Generator = "MarkdownSharp";
            }

            return(ProcessTableOfContents(fileContents));
        }
コード例 #3
0
ファイル: MarkdownWebPage.cs プロジェクト: pakrym/NuGetDocs
        /// <summary>
        /// Transforms the raw markdown content into html
        /// </summary>
        private string Transform(string content)
        {
            var githubMarkdown = new Octokit.MiscellaneousClient(new Octokit.Connection(new Octokit.ProductHeaderValue("NuGet.Docs")));
            string fileContents = null;

            try
            {
                // Try to transform the content using GitHub's API
                var request = githubMarkdown.RenderRawMarkdown(content);
                request.Wait();

                if (request.IsCompleted)
                {
                    fileContents = request.Result
                        .Replace("<table>", "<table class=\"reference\">")
                        .Replace("<p>\n<strong>Note", "<p class=\"info\">\n<strong>Note")
                        .Replace("<p>\n<strong>Caution", "<p class=\"caution\">\n<strong>Caution")
                        .Replace("<div>\n<strong>Caution", "<div class=\"caution\">\n<strong>Caution");
                    Page.Generator = "GitHub";
                }
            }
            catch
            {
                // If the call to GitHub failed, then we'll swallow the exception
                // and in the finally block, we'll use MarkdownSharp as a fallback.
            }
            finally
            {
                if (fileContents == null)
                {
                    fileContents = new Markdown().Transform(content);
                    Page.Generator = "MarkdownSharp";
                }
            }

            return ProcessTableOfContents(fileContents);
        }