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


C# Markdown.Transform方法代码示例

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


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

示例1: Configure

        public static void Configure()
        {
            var options = new MarkdownOptions { AutoHyperlink = true };
            var converter = new Markdown(options);

            Mapper.CreateMap<Entry, EntryViewModel>()
                // convert content from markdown to html
                .ForMember(entry => entry.Content,
                    expression => expression.ResolveUsing(source => converter.Transform(source.Content)))
                // convert summary from markdown to html
                .ForMember(entry => entry.Summary,
                    expression => expression.ResolveUsing(source => converter.Transform(source.Summary)));

            // convert the closed type of the derived generic list
            Mapper.CreateMap<PagedList<Entry>, PagedList<EntryViewModel>>()
                .AfterMap((entity, model) => Mapper.Map<List<Entry>, List<EntryViewModel>>(entity, model));

            Mapper.CreateMap<EntryInput, Entry>()
                .ForMember(entry => entry.Slug, expression => expression.MapFrom(
                    entry => SlugConverter.Convert(entry.Header)))
                .ForMember(entry => entry.Tags, expression => expression.MapFrom(
                    entry => TagsResolver.ResolveTags(entry.Tags)));

            Mapper.CreateMap<Entry, EntryInput>()
                .ForMember(entry => entry.Tags, opt => opt.MapFrom(
                    entry => TagsResolver.ResolveTags(entry.Tags)));

            Mapper.CreateMap<Entry, EntryInput>();
        }
开发者ID:niekert,项目名称:GoBlog,代码行数:29,代码来源:AutoMapperConfiguration.cs

示例2: TestEncodeProblemUrlCharacters

 public void TestEncodeProblemUrlCharacters()
 {
     var markdown = new Markdown();
     Assert.IsFalse(markdown.EncodeProblemUrlCharacters);
     Assert.AreEqual("<p><a href=\"/'*_[]()/\">Foo</a></p>\n", markdown.Transform("[Foo](/'*_[]()/)"));
     markdown.EncodeProblemUrlCharacters = true;
     Assert.AreEqual("<p><a href=\"/%27%2a%5f%5b%5d%28%29/\">Foo</a></p>\n", markdown.Transform("[Foo](/'*_[]()/)"));
 }
开发者ID:gaufung,项目名称:MarkdownSharp,代码行数:8,代码来源:ConfigTest.cs

示例3: TestAutoHyperlink

 public void TestAutoHyperlink()
 {
     var markdown = new Markdown();  
     Assert.IsFalse(markdown.AutoHyperlink);
     Assert.AreEqual("<p>foo http://example.com bar</p>\n", markdown.Transform("foo http://example.com bar"));
     markdown.AutoHyperlink = true;
     Assert.AreEqual("<p>foo <a href=\"http://example.com\">http://example.com</a> bar</p>\n", markdown.Transform("foo http://example.com bar"));
 }
开发者ID:sassembla,项目名称:markdownsharp,代码行数:8,代码来源:ConfigTest.cs

示例4: TestEmptyElementSuffix

 public void TestEmptyElementSuffix()
 {
     var markdown = new Markdown();
     Assert.AreEqual(" />", markdown.EmptyElementSuffix);
     Assert.AreEqual("<hr />\n", markdown.Transform("* * *"));
     markdown.EmptyElementSuffix = ">";
     Assert.AreEqual("<hr>\n", markdown.Transform("* * *"));
 }
开发者ID:sassembla,项目名称:markdownsharp,代码行数:8,代码来源:ConfigTest.cs

示例5: TestAutoNewLines

 public void TestAutoNewLines()
 {
     var markdown = new Markdown();
     Assert.IsFalse(markdown.AutoNewLines);
     Assert.AreEqual("<p>Line1\nLine2</p>\n", markdown.Transform("Line1\nLine2"));
     markdown.AutoNewLines = true;
     Assert.AreEqual("<p>Line1<br />\nLine2</p>\n", markdown.Transform("Line1\nLine2"));
 }
开发者ID:sassembla,项目名称:markdownsharp,代码行数:8,代码来源:ConfigTest.cs

示例6: TestLinkEmails

 public void TestLinkEmails()
 {
     var markdown = new Markdown();
     Assert.IsTrue(markdown.LinkEmails);
     Assert.AreEqual("<p><a href=\"&#", markdown.Transform("<[email protected]>").Substring(0,14));
     markdown.LinkEmails = false;
     Assert.AreEqual("<p><[email protected]></p>\n", markdown.Transform("<[email protected]>"));
 }
开发者ID:sassembla,项目名称:markdownsharp,代码行数:8,代码来源:ConfigTest.cs

示例7: RenderView

        public Response RenderView(ViewLocationResult viewLocationResult, dynamic model, IRenderContext renderContext)
        {
            var response = new HtmlResponse();

            var html = renderContext.ViewCache.GetOrAdd(viewLocationResult, result =>
                                                                                {
                                                                                    string markDown =
                                                                                        viewLocationResult.Contents()
                                                                                                          .ReadToEnd();


                                                                                    var parser = new Markdown();
                                                                                    return parser.Transform(markDown);
                                                                                });


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

            var renderHtml = this.engineWrapper.Render(serverHtml, model, new MarkdownViewEngineHost(new NancyViewEngineHost(renderContext), renderContext));

            response.Contents = stream =>
            {
                var writer = new StreamWriter(stream);
                writer.Write(renderHtml);
                writer.Flush();
            };

            return response;
        }
开发者ID:jchannon,项目名称:Nancy.ViewEngines.Markdown,代码行数:29,代码来源:MarkDownEngine.cs

示例8: SendEmail

        public static void SendEmail(Suggestion suggestion)
        {
            var markdown = new Markdown();
            var appName = WebConfigurationManager.AppSettings["AppName"];
            var appUrl = WebConfigurationManager.AppSettings["AppUrl"];
            var smtpServer = WebConfigurationManager.AppSettings["SmtpServer"];
            var fromAddress = WebConfigurationManager.AppSettings["EmailFrom"];
            var toAddress = WebConfigurationManager.AppSettings["EmailTo"];

            var subject = string.Format("{0}: {1}", appName, suggestion.Title);
            var body = string.Format(@"<p>""{0}""  has been submitted to {1}.</p>
            {2}
            <p>You can view the suggestion <a href=""{3}Suggestions/View/{4}"">here</a>.</p>", suggestion.Title, appName, markdown.Transform(suggestion.Body), appUrl, suggestion.Id);

            var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            };

            var client = new SmtpClient(smtpServer);

            client.Send(message);
        }
开发者ID:Praeses,项目名称:SuggestionBox,代码行数:25,代码来源:SuggestionEmailer.cs

示例9: Parse

        public static Post Parse(string fileData)
        {
            var lines = fileData.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            var metadata = new Dictionary<string, string>();

            if (lines.Any() && lines[0] != "---")
            {
                return null;
            }

            var ii = 1;
            for (; ii < lines.Length; ii++ )
            {
                if (lines[ii] == "---")
                {
                    break;
                }

                var parts = lines[ii].Split(':');
                metadata.Add(parts[0].Trim(), parts[1].Trim());
            }

            var content = string.Join(Environment.NewLine, lines.Skip(ii + 1).ToArray());

            var md = new Markdown();

            return new Post
            {
                Title = metadata["title"],
                PublishDate = DateTime.Parse(metadata["date"]),
                Content = md.Transform(content)
            };
        }
开发者ID:tutsplus,项目名称:build-a-git-powered-cms-with-aspnet,代码行数:33,代码来源:Post.cs

示例10: transform

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

            var parser = new Markdown();
            parser.ExtendWith(new StatefulCheckboxPattern());

            var t = parser.Transform(text);

            //prevent html from being replaced by wikiwords
            var htmlTags = new Queue<string>();
            t = _htmlTagsRegex.Replace(t, m =>
            {
                htmlTags.Enqueue(m.Groups[0].Value);
                return _emaPlaceholder;
            });

            //don't extend markdown with this pattern because it will destroy links
            t = new WikiWordsPattern().Transform(t);

            return _htmlTagsRegex.Replace(t, m =>
            {
                if (m.Groups[0].Value == _emaPlaceholder)
                {
                    return htmlTags.Dequeue();
                }
                else
                {
                    //new wikiword link
                    return m.Groups[0].Value;
                }
            });
        }
开发者ID:KhalidElSayed,项目名称:Ema-Personal-Wiki,代码行数:34,代码来源:PagesDal.cs

示例11: Execute

		public string Execute(string source, IDictionary<string, object> arguments)
		{
			var markdown = new Markdown();
			string output = markdown.Transform(source);
			
			return output;
		}
开发者ID:wilsonmar,项目名称:mulder,代码行数:7,代码来源:MarkdownFilter.cs

示例12: Process

 public string Process(string input)
 {
     var options = new MarkdownOptions();
     var markdown = new Markdown();
     var output = markdown.Transform(input);
     return output;
 }
开发者ID:typeset,项目名称:typeset,代码行数:7,代码来源:MarkdownProcessor.cs

示例13: FormatLogEntry

        private SyndicationItem FormatLogEntry(LogEntry entry, string repo)
        {
            var markdownParser = new Markdown(true);
            var item = new SyndicationItem();

            item.Id = entry.CommitHash;
            item.Title = new TextSyndicationContent(entry.Subject);
            item.Content = SyndicationContent.CreateHtmlContent(markdownParser.Transform(entry.Subject + "\n\n" + entry.Body));
            item.LastUpdatedTime = entry.AuthorDate;
            item.PublishDate = entry.CommitterDate;

            item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(Url.Action("ViewCommit", "Browse", new { repo, @object = entry.CommitHash }), UriKind.Relative)));

            item.Categories.Add(new SyndicationCategory("commit"));
            if (entry.Parents.Count > 1)
            {
                item.Categories.Add(new SyndicationCategory("merge"));
            }

            item.Authors.Add(new SyndicationPerson(entry.AuthorEmail, entry.Author, null));
            if (entry.Author != entry.Committer || entry.AuthorEmail != entry.CommitterEmail)
            {
                item.Contributors.Add(new SyndicationPerson(entry.CommitterEmail, entry.Committer, null));
            }

            return item;
        }
开发者ID:JasSra,项目名称:WebGitNet,代码行数:27,代码来源:SyndicationController.cs

示例14: Main

 public static void Main(string[] args)
 {
     Markdown md = new Markdown ();
     var markup = File.ReadAllText (args[0]);
     var html = md.Transform (markup);
     Console.WriteLine (html);
 }
开发者ID:Dynalon,项目名称:MarkdownSharp,代码行数:7,代码来源:Main.cs

示例15: ProcessRequest

        public void ProcessRequest(HttpContext context) {
            context.Response.ContentType = "text/html";

            var markdown = context.Request.QueryString["markdown"];
            var processor = new Markdown();
            context.Response.Write(processor.Transform(markdown));
        }
开发者ID:cmarfia,项目名称:KalikoCMS.Core,代码行数:7,代码来源:MarkdownHandler.ashx.cs


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