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


C# MarkdownSharp.Markdown.Transform方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例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: Transform

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

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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: TranslateWithStyle

        public static string TranslateWithStyle(string markdownText)
        {
            var lMarkdown = new MarkdownSharp.Markdown();

            var lStyleSheet = Properties.Resources.PreviewStyleSheet;
            var lHeader = Properties.Settings.Default.MarkdownStyleHeader + lStyleSheet + Properties.Settings.Default.MarkdownBodyHeader;
            var lBody = lMarkdown.Transform(markdownText);
            var lFooter = Properties.Settings.Default.MarkdownBodyFooter;
            return lHeader + lBody + lFooter;
        }
开发者ID:cmprog,项目名称:IssueTracker,代码行数:10,代码来源:MarkdownHelper.cs

示例13: Transform

        public static string Transform(string input)
        {
            //MarkdownSharp.MarkdownOptions mdo = new MarkdownSharp.MarkdownOptions();
            //mdo.AutoHyperlink = true;
            //mdo.AutoNewlines = true;
            MarkdownSharp.Markdown md = new MarkdownSharp.Markdown(); //mdo);
            md.AutoHyperlink = true;

            return md.Transform(input);
        }
开发者ID:dallasseminary,项目名称:Didache,代码行数:10,代码来源:Markdown.cs

示例14: Transform

        public string Transform(string markdownText, string baseUrl)
        {
            // TODO Valutare se usare un'altra libreria per performance migliori
            //  e perchè credo che questa non supporta il multithreading e bisogna ricreare ogni volta l'istanza. Da verificare.

            var markdown = new MarkdownSharp.Markdown();
            markdown.BaseUrl = baseUrl;

            return markdown.Transform(markdownText);
        }
开发者ID:davideicardi,项目名称:xrc,代码行数:10,代码来源:MarkdownService.cs

示例15: Get

		/// <summary>
		/// Gets the block with the given internal id.
		/// </summary>
		/// <param name="internalId">The internal id</param>
		/// <returns>The block content as html</returns>
		public static IHtmlString Get(string internalId) {
			using (var rep = new Goldfish.Blocks.Api()) {
				var block = rep.GetByInternalId(internalId);

				if (block != null) {
					var converter = new MarkdownSharp.Markdown();
					return new HtmlString(converter.Transform(block.Body));
				}
				return new HtmlString("");
			}
		}
开发者ID:nguyenhoangthanh,项目名称:Goldfish,代码行数:16,代码来源:Blocks.cs


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