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


C# MarkdownSharp.Markdown类代码示例

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


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

示例1: Show

        public ActionResult Show([Bind(Prefix = "id")] string slug)
        {
            if (string.IsNullOrWhiteSpace(slug))
                throw new ArgumentNullException("slug");

            Entry entry;
            try
            {
                entry = Services.Entry.GetBySlug(slug);
            }
            catch (Exception ex)
            {
                throw new HttpException(404, "Entry not found", ex);
            }

            var markdown = new MarkdownSharp.Markdown();
            var html = markdown.Transform(entry.Markdown);

            var model = new ShowModel
            {
                Date = entry.DateCreated.ToString("dddd, dd MMMM yyyy"),
                Slug = entry.Slug,
                Title = entry.Title,
                Html = html,
                IsCodePrettified = entry.IsCodePrettified ?? true
            };

            return View(model);
        }
开发者ID:4Rebin,项目名称:NBlog,代码行数:29,代码来源:EntryController.cs

示例2: AboutVoodoo

        public AboutVoodoo()
        {
            InitializeComponent();

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                Stream textStream = assembly.GetManifestResourceStream("VoodooUI.Resources.about.md");
                StreamReader textStreamReader = new StreamReader(textStream);

                String text = new StreamReader(textStream).ReadToEnd();

                MarkdownSharp.MarkdownOptions mdopt = new MarkdownSharp.MarkdownOptions();
                mdopt.AutoHyperlink = true; mdopt.LinkEmails = true;
                MarkdownSharp.Markdown parser = new MarkdownSharp.Markdown(mdopt);

                text = parser.Transform(text);
                webBrowser1.DocumentText = text;

                textStreamReader.Close();
            }
            catch (Exception exc)
            {
                webBrowser1.DocumentText = "Voodoo Shader Framework<br>\nCopyright (c) 2010-2013 by Sean Sube, All Rights Reserved.<br>\n<br>\nError loading info:<br>\n\t" + exc.Message;
            }

            m_NoNav = true;
        }
开发者ID:ssube,项目名称:VoodooShader,代码行数:28,代码来源:AboutVoodoo.cs

示例3: RenderMasterPage

        /// <summary>
        /// Renders stand alone / master page
        /// </summary>
        /// <param name="templateContent">Template content</param>
        /// <returns>HTML converted to markdown</returns>
        public static string RenderMasterPage(string templateContent)
        {
            var second =
               templateContent.Substring(
                   templateContent.IndexOf("<!DOCTYPE html>", StringComparison.OrdinalIgnoreCase),
                   templateContent.IndexOf("<body", StringComparison.OrdinalIgnoreCase));

            var third = templateContent.Substring(second.Length);

            var forth = templateContent.Substring(second.Length, third.IndexOf(">", StringComparison.Ordinal) + 1);

            var header = second + forth;

            var toConvert = templateContent.Substring(header.Length,
                                                      (templateContent.IndexOf("</body>", StringComparison.Ordinal) -
                                                       (templateContent.IndexOf(forth, StringComparison.Ordinal) + forth.Length)));

            var footer =
                templateContent.Substring(templateContent.IndexOf("</body>", StringComparison.OrdinalIgnoreCase));

            var parser = new MarkdownSharp.Markdown();

            var html = parser.Transform(toConvert.Trim());

            var serverHtml = ParagraphSubstitution.Replace(html, "$1");

            //TODO: The "Replace" is simply for unit testing HTML/MD strings. Probably needs improving
            return string.Concat(header, serverHtml, footer).Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
        }
开发者ID:JulianRooze,项目名称:Nancy,代码行数:34,代码来源:MarkdownViewengineRender.cs

示例4: GenerateCode

        /// <summary>
        /// Function that builds the contents of the generated file based on the contents of the input file
        /// </summary>
        /// <param name="inputFileContent">Content of the input file</param>
        /// <returns>Generated file as a byte array</returns>
        protected override byte[] GenerateCode(string inputFileContent)
        {
            try
            {               
                //If the input file doesn't contain an inline output extension then use the file namespace,
                if (new Regex(@"(\.\w+)\" + Path.GetExtension(InputFilePath))
                    .Match(Path.GetFileName(InputFilePath)).Groups.Count == 1)
                {
                    DefaultExtension = "." + this.FileNameSpace;
                }
                else //leave the default extension blank to use the inline extension
                {
                    DefaultExtension = string.Empty;
                }

                var input = File.ReadAllText(InputFilePath);
                var md = new MarkdownSharp.Markdown();
                var output = md.Transform(input);
                return ConvertToBytes(output);
            }
            catch (Exception exception)
            {
                GeneratorError(0, exception.Message, 0, 0);
            }

            return null;
        }
开发者ID:idiotandrobot,项目名称:Markdown-For-Visual-Studio,代码行数:32,代码来源:Markdown.cs

示例5: MarkdownReplace

        private static string MarkdownReplace(string text) {
            if (string.IsNullOrEmpty(text))
                return string.Empty;

            var markdown = new MarkdownSharp.Markdown();
            return markdown.Transform(text);
        }
开发者ID:sjbisch,项目名称:Orchard,代码行数:7,代码来源:MarkdownFilter.cs

示例6: MarkdownViewEngineHost

 public MarkdownViewEngineHost(IViewEngineHost viewEngineHost, IRenderContext renderContext)
 {
     this.viewEngineHost = viewEngineHost;
     this.renderContext = renderContext;
     this.Context = this.renderContext.Context;
     this.parser = new MarkdownSharp.Markdown();
 }
开发者ID:jchannon,项目名称:Nancy.ViewEngines.Markdown,代码行数:7,代码来源:MarkdownViewEngineHost.cs

示例7: GenerateCode

        /// <summary>
        /// Function that builds the contents of the generated file based on the contents of the input file
        /// </summary>
        /// <param name="inputFileContent">Content of the input file</param>
        /// <returns>Generated file as a byte array</returns>
        protected override byte[] GenerateCode(string inputFileContent)
        {

            //if (InputFilePath.EndsWith("_md"))
            var mdRegex = new System.Text.RegularExpressions.Regex(@"\w+\.\w+_md");
            if (mdRegex.IsMatch(Path.GetFileName(InputFilePath)))
            {
                try
                {
                    var input = File.ReadAllText(InputFilePath);
                    var md = new MarkdownSharp.Markdown();
                    var output = md.Transform(input);
                    return ConvertToBytes(output);
                }
                catch (Exception exception)
                {
                    GeneratorError(0, exception.Message, 0, 0);
                }
            }
            else
            {
                GeneratorError(0, "The Markdown tool is only for Markdown files with the following filename format: filename.[required_extension]_md", 0, 0);
            }

            return null;
        }
开发者ID:stachow,项目名称:Markdown-For-Visual-Studio,代码行数:31,代码来源:Markdown.cs

示例8: Transform

        public string Transform(string input)
        {
            var md = new MarkdownSharp.Markdown();
            var outputContent = md.Transform(input);

            return outputContent;
        }
开发者ID:hmeydac,项目名称:Homeworld,代码行数:7,代码来源:MarkdownSharpEngine.cs

示例9: GenerateCode

        /// <summary>
        /// Function that builds the contents of the generated file based on the contents of the input file
        /// </summary>
        /// <param name="inputFileContent">Content of the input file</param>
        /// <returns>Generated file as a byte array</returns>
        protected override byte[] GenerateCode(string inputFileContent)
        {

            var mdRegex = new System.Text.RegularExpressions.Regex(@"(\.\w+)\.(?:md|markdown)$");
            var matches = mdRegex.Match(Path.GetFileName(InputFilePath));

            if (matches.Groups.Count > 1)
            {
                try
                {
                    var input = File.ReadAllText(InputFilePath);
                    var md = new MarkdownSharp.Markdown();
                    var output = md.Transform(input);
                    return ConvertToBytes(output);
                }
                catch (Exception exception)
                {
                    GeneratorError(0, exception.Message, 0, 0);
                }
            }
            else
            {
                GeneratorError(0, "The Markdown tool is only for Markdown files with the following filename format: filename.[required_extension].md or filename.[required_extension].markdown", 0, 0);
            }

            return null;
        }
开发者ID:wheelibin,项目名称:Markdown-For-Visual-Studio,代码行数:32,代码来源:Markdown.cs

示例10: Write

        public static void Write(HttpContext context, string file)
        {
            var md = new MarkdownSharp.Markdown();
            context.Response.ContentType = "text/html";

            // < html xmlns = ""http://www.w3.org/1999/xhtml"">
            context.Response.Output.Write(@"<!DOCTYPE html>
            <html>
            <head>
            <meta http-equiv=""X-UA-Compatible"" content=""IE=edge,chrome=1"" />
            <meta charset=""utf-8"">
            <meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />
            <title>");

            context.Response.Output.Write(System.IO.Path.GetFileNameWithoutExtension(file));

            context.Response.Output.Write(@"</title>
            <meta http-equiv=""cache-control"" content=""max-age=0"" />
            <meta http-equiv=""cache-control"" content=""no-cache"" />
            <meta http-equiv=""expires"" content=""0"" />
            <meta http-equiv=""expires"" content=""Tue, 01 Jan 1980 1:00:00 GMT"" />
            <meta http-equiv=""pragma"" content=""no-cache"" />

            <base href =""/ajax/Resource.ashx/");
            context.Response.Output.Write(System.Web.HttpUtility.UrlPathEncode(
            Base64Encode(System.IO.Path.GetDirectoryName(file))
             ));
            context.Response.Output.Write(@"/"" />
            <link rel=""canonical"" href=""");

            string str = new System.Uri(file).AbsoluteUri;
            context.Response.Output.Write(str);

            context.Response.Output.Write(@""" />");

            context.Response.Output.Write("<style type=\"text/css\">");

            // http://stackoverflow.com/questions/6784799/what-is-this-char-65279
            // It's a zero-width no-break space. It's more commonly used as a byte-order mark (BOM).
            // context.Response.WriteFile(System.Web.Hosting.HostingEnvironment.MapPath("~/style.css"));
            // http://www.fileformat.info/info/unicode/char/feff/index.htm
            // \32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\64\102\111\110\116\45\102\97\99\101\32\123
            // \32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\32\65279\64\102\111\110\116\45\102\97\99\101\32\123

            context.Response.Output.Write(
                System.IO.File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/style.css"), System.Text.Encoding.UTF8)
            );
            context.Response.Output.Write("</style>");

            context.Response.Output.Write(@"
            <link type=""text/css"" rel=""stylesheet"" href=""Content/style.css"" />
            <script type=""text/javascript"" src=""./Scripts/libs/jquery.js""></script>
            </head>
            <body>
            ");

            context.Response.Output.Write(md.Transform(System.IO.File.ReadAllText(file)));
            context.Response.Output.Write(@"</body></html>");
        }
开发者ID:ststeiger,项目名称:Svg3Dtest,代码行数:59,代码来源:MarkDownWriter.cs

示例11: MarkdownViewEngineHost

 /// <summary>
 /// Initializes a new instance of the <see cref="MarkdownViewEngineHost"/> class.
 /// </summary>
 /// <param name="viewEngineHost">A decorator <see cref="IViewEngineHost"/></param>
 /// <param name="renderContext">The render context.</param>
 /// <param name="viewExtensions">The allowed extensions</param>
 public MarkdownViewEngineHost(IViewEngineHost viewEngineHost, IRenderContext renderContext, IEnumerable<string> viewExtensions)
 {
     this.viewEngineHost = viewEngineHost;
     this.renderContext = renderContext;
     this.validExtensions = viewExtensions;
     this.Context = this.renderContext.Context;
     this.parser = new MarkdownSharp.Markdown();
 }
开发者ID:jbattermann,项目名称:Nancy,代码行数:14,代码来源:MarkdownViewEngineHost.cs

示例12: MarkdownFormat

        public MarkdownFormat()
        {
            markdown = new MarkdownSharp.Markdown();

            this.MarkdownBaseType = typeof(MarkdownViewBase);
            this.MarkdownGlobalHelpers = new Dictionary<string, Type>();
            this.FindMarkdownPagesFn = FindMarkdownPages;
        }
开发者ID:bman654,项目名称:ServiceStack,代码行数:8,代码来源:MarkdownFormat.cs

示例13: ConvertToHtml

 private string ConvertToHtml(string source)
 {
     var md = new MarkdownSharp.Markdown();
     md.AddExtension(new GitHubCodeBlockExtension());
     var html = md.Transform(source);
     html = CleanHtml(html);
     return html;
 }
开发者ID:mastersign,项目名称:bench,代码行数:8,代码来源:MarkdownHtmlConverter.cs

示例14: Transform

        public string Transform(string input)
        {
            var md = new MarkdownSharp.Markdown();
            return md.Transform(input);

            //var md = new anrControls.Markdown();
            //return md.Transform(input);
        }
开发者ID:junsukenttr,项目名称:MarkdownView,代码行数:8,代码来源:Translator.cs

示例15: ConvertMarkdownToHtml

        private static void ConvertMarkdownToHtml(string file, string outputfile)
        {
            string input = File.ReadAllText(file);
            var output = new MarkdownSharp.Markdown().Transform(input);

            EnsureDirectoryExists(Path.GetDirectoryName(outputfile));
            File.WriteAllText(outputfile,output);
        }
开发者ID:paveltimofeev,项目名称:documentation,代码行数:8,代码来源:Program.cs


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