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


C# Markdown.Transform方法代码示例

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


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

示例1: Simple

		public void Simple()
		{
			var markdown = new Markdown
			{
				NewWindowForExternalLinks = true
			};
			Console.WriteLine(markdown.Transform("##Header"));
			Console.WriteLine(markdown.Transform("`<T>`"));
			Console.WriteLine(markdown.Transform("[a](http://e1.ru)"));
		}
开发者ID:hexandr,项目名称:uLearn,代码行数:10,代码来源:Markdown_investigation.cs

示例2: CompiledContent

        public static MvcHtmlString CompiledContent(this IDynamicContent contentItem, bool trustContent)
        {
            if (contentItem == null) return MvcHtmlString.Empty;

            switch (contentItem.ContentType)
            {
                case DynamicContentType.Markdown:
                    var md = new Markdown
                    {
                        AutoHeadingIDs = true,
                        ExtraMode = true,
                        NoFollowLinks = !trustContent,
                        SafeMode = false,
                        NewWindowForExternalLinks = true,
                    };

                    var contents = contentItem.Body;
                    contents = CodeBlockFinder.Replace(contents, match => GenerateCodeBlock(match.Groups[1].Value.Trim(), match.Groups[2].Value));

                    try
                    {
                        contents = md.Transform(contents);
                    }
                    catch (Exception)
                    {
                        contents = string.Format("<pre>{0}</pre>", HttpUtility.HtmlEncode(contents));
                    }

                    return MvcHtmlString.Create(contents);
                case DynamicContentType.Html:
                    return trustContent ? MvcHtmlString.Create(contentItem.Body) : MvcHtmlString.Empty;
            }
            return MvcHtmlString.Empty;
        }
开发者ID:OpenMind,项目名称:VulcanBlog,代码行数:34,代码来源:DynamicContentHelpers.cs

示例3: ResolveMarkdown

        public static string ResolveMarkdown(this string content, IDocsOutput output, string currentSlug)
        {
            // http://www.toptensoftware.com/markdowndeep/api
            var md = new Markdown
                        {
                            AutoHeadingIDs = true,
                            ExtraMode = true,
                            NoFollowLinks = false,
                            SafeMode = false,
                            HtmlClassTitledImages = "figure",
                            UrlRootLocation = output.RootUrl,
                        };

            if (!string.IsNullOrWhiteSpace(output.RootUrl))
            {
                if (!string.IsNullOrWhiteSpace(currentSlug) && !currentSlug.Equals("index"))
                    md.UrlBaseLocation = output.RootUrl + "/" + currentSlug.Replace('\\', '/');
                else
                    md.UrlBaseLocation = output.RootUrl;
            }

            ////if (!string.IsNullOrWhiteSpace(output.ImagesPath))
            //    md.QualifyUrl = delegate(string image) { return output.ImagesPath + "/" + image; };

            md.PrepareImage = (tag, titledImage) => PrepareImage(output.ImagesPath, tag);

            return md.Transform(content);
        }
开发者ID:kyanha,项目名称:docs,代码行数:28,代码来源:DocumentationParser.cs

示例4: Main

        static void Main(string[] args)
        {
            Markdown m = new Markdown();
            m.SafeMode = false;
            m.ExtraMode = true;
            m.AutoHeadingIDs = true;
            //			m.SectionHeader = "<div class=\"header\">{0}</div>\n";
            //			m.SectionHeadingSuffix = "<div class=\"heading\">{0}</div>\n";
            //			m.SectionFooter = "<div class=\"footer\">{0}</div>\n\n";
            //			m.SectionHeader = "\n<div class=\"section_links\"><a href=\"/edit?section={0}\">Edit</a></div>\n";
            //			m.HtmlClassTitledImages = "figure";
            //			m.DocumentRoot = "C:\\users\\bradr\\desktop";
            //			m.DocumentLocation = "C:\\users\\bradr\\desktop\\100D5000";
            //			m.MaxImageWidth = 500;

            string markdown=FileContents("input.txt");
            string str = m.Transform(markdown);
            Console.Write(str);

            var sections = MarkdownDeep.Markdown.SplitSections(markdown);
            for (int i = 0; i < sections.Count; i++)
            {
                Console.WriteLine("---- Section {0} ----", i);
                Console.Write(sections[i]);
                Console.WriteLine("\n");
            }
            Console.WriteLine("------------------");
        }
开发者ID:arronei,项目名称:markdowndeep,代码行数:28,代码来源:Program.cs

示例5: GetDocument

 private Negotiator GetDocument(IDocumentFolder documentFolder, string path)
 {
     var markdown = documentFolder.ReadAllText(path);
     var converter = new Markdown();
     var html = converter.Transform(markdown);
     return View["Index", new { Title = path, Content = html }];
 }
开发者ID:rlipscombe,项目名称:vs-welcome-page,代码行数:7,代码来源:HomeModule.cs

示例6: Markdown

 public static string Markdown(string text)
 {
     if (text == null)
         return "";
     var md = new Markdown();
     return md.Transform(text.Trim());
 }
开发者ID:clearfunction,项目名称:bvcms,代码行数:7,代码来源:Misc.cs

示例7: CompiledContent

        public static IHtmlString CompiledContent(this IDynamicContent contentItem, bool trustContent = false)
        {
            if (contentItem == null) return NonEncodedHtmlString.Empty;

            switch (contentItem.ContentType)
            {
                case DynamicContentType.Markdown:
                    var md = new Markdown
                    {
                        AutoHeadingIDs = true,
                        ExtraMode = true,
                        NoFollowLinks = !trustContent,
                        SafeMode = false,
                        NewWindowForExternalLinks = true,
                    };

                    var contents = contentItem.Content;
                    // TODO contents = CodeBlockFinder.Replace(contents, match => GenerateCodeBlock(match.Groups[1].Value.Trim(), match.Groups[2].Value));
                    contents = md.Transform(contents);
                    return new NonEncodedHtmlString(contents);
                case DynamicContentType.Html:
                    return trustContent ? new NonEncodedHtmlString(contentItem.Content) : NonEncodedHtmlString.Empty;
            }
            return NonEncodedHtmlString.Empty;
        }
开发者ID:jchannon,项目名称:NSemble,代码行数:25,代码来源:DynamicContentHelpers.cs

示例8: Show

        public ActionResult Show(string page)
        {
            if (page == "" || page == null)
                page = "README";
            string path = string.Concat(HttpContext.Request.PhysicalApplicationPath, "\\Docs\\", page, ".md");
            string contents;

            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    Markdown md = new Markdown();
                    contents = md.Transform(sr.ReadToEnd());

                }

                ViewBag.ConvertedMarkdown = contents;
                return View();
            }
            catch (Exception ex)
            {
                this.Response.StatusCode = 404;
                ViewBag.ConvertedMarkdown = "File not found.";
                return View();
            }
        }
开发者ID:szwork2013,项目名称:BoiPlt,代码行数:26,代码来源:DocsController.cs

示例9: ShowReleaseNotesDialog_Load

		private void ShowReleaseNotesDialog_Load(object sender, EventArgs e)
		{
			string contents = File.ReadAllText(_path);

			var md = new Markdown();
			_temp = TempFile.WithExtension("htm"); //enhance: will leek a file to temp
			File.WriteAllText(_temp.Path, md.Transform(contents));
			_browser.Url = new Uri(_temp.Path);
		}
开发者ID:jwickberg,项目名称:libpalaso,代码行数:9,代码来源:ShowReleaseNotesDialog.cs

示例10: Markdown

        /// <summary>
        /// Transforms a string of Markdown into HTML.
        /// </summary>
        /// <param name="text">The Markdown that should be transformed.</param>
        /// <returns>The HTML representation of the supplied Markdown.</returns>
        public static IHtmlString Markdown(string text)
        {
            // Transform the supplied text (Markdown) into HTML.
            var markdownTransformer = new Markdown();
            var html = markdownTransformer.Transform(text);

            // Wrap the html in an MvcHtmlString otherwise it'll be HtmlEncoded and displayed to the user as HTML :(
            return html.ToHtmlString();
        }
开发者ID:Code52,项目名称:Ideastrike,代码行数:14,代码来源:MarkdownHelper.cs

示例11: ShowReleaseNotesDialog_Load

		private void ShowReleaseNotesDialog_Load(object sender, EventArgs e)
		{
			string contents = File.ReadAllText(_path);

			var md = new Markdown();
			// Disposed of during dialog Dispose()
			_temp = TempFile.WithExtension("htm");
			File.WriteAllText(_temp.Path, GetBasicHtmlFromMarkdown(md.Transform(contents)));
			_browser.Url = new Uri(_temp.Path);
		}
开发者ID:regnrand,项目名称:libpalaso,代码行数:10,代码来源:ShowReleaseNotesDialog.cs

示例12: TransformMarkdown

        public void TransformMarkdown()
        {
            var markdownEngine = new Markdown
            {
                ExtraMode = true,
                AutoHeadingIDs = true,
                CodeBlockLanguageAttr = " data-language=\"{0}\""
            };

            this.Body = markdownEngine.Transform(this.Body);
        }
开发者ID:rdumont,项目名称:frankie,代码行数:11,代码来源:ContentFile.cs

示例13: Markdown

 public static string Markdown(this string txt)
 {
     if (string.IsNullOrEmpty(txt)) return string.Empty;
     // spaces in urls will not work with MarkdownDeep
     txt = Regex.Replace(txt, @"\(http(.*)\)", match => match.ToString().Replace(" ", "%20"));
     // single linebreaks become double linebreaks to conform LeTour markdown
     var md = new Markdown();
     txt = md.Transform(txt);
     txt = Regex.Replace(txt, @"(?<!(</p>))\n(?!\n)", match => "<br/>");
     return txt;
 }
开发者ID:MartinZulu,项目名称:LeTour,代码行数:11,代码来源:StringHelper.cs

示例14: Render

        public void Render(Document input, Document output)
        {
            output.Extension = ".html";
            var mark = new Markdown();

            //set preferences of your markdown
            mark.SafeMode = true;
            mark.ExtraMode = true;
            
            string mdtext = input.Text;
            output.Text = mark.Transform(mdtext);
        }
开发者ID:Xperterra,项目名称:Fhir.Publication,代码行数:12,代码来源:MarkdownRenderer.cs

示例15: FormatMessage

        public static string FormatMessage(String originalMessage, bool processContent = true)
        {
            //Test changes to this code against this markdown thread content:
            //https://voat.co/v/test/comments/53891

            if (processContent && !String.IsNullOrEmpty(originalMessage))
            {
                originalMessage = ContentProcessor.Instance.Process(originalMessage, ProcessingStage.Outbound, null);
            }

            var newWindow = false;

            if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                newWindow = UserHelper.LinksInNewWindow(System.Web.HttpContext.Current.User.Identity.Name);
            }

            var m = new Markdown
            {
                PrepareLink = new Func<HtmlTag, bool>(x =>
                {
                    //Remove [Title](javascript:alter('hello')) exploit
                    string href = x.attributes["href"];
                    if (!String.IsNullOrEmpty(href))
                    {
                        //I think it needs the javascript: prefix to work at all but there might be more holes as this is just a simple check.
                        if (href.ToLower().Trim().StartsWith("javascript:"))
                        {
                            x.attributes["href"] = "#";
                            //add it to the output for verification?
                            x.attributes.Add("data-ScriptStrip", String.Format("/* script detected: {0} */", href));
                        }
                    }
                    return true;
                }),
                ExtraMode = true,
                SafeMode = true,
                NewWindowForExternalLinks = newWindow,
                NewWindowForLocalLinks = newWindow
            };

            try
            {
                return m.Transform(originalMessage);
            }
            catch (Exception ex)
            {
                return "Content contains unsafe or unknown tags.";
            }
        }
开发者ID:Rumel,项目名称:voat,代码行数:50,代码来源:Formatting.cs


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