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


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

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


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

示例1: PreviewForUnpublishedPostTest

        public void PreviewForUnpublishedPostTest()
        {
            IRepository<Post> postRepo = new SimpleRepository<Post>(new InMemoryRepositoryDataSource<Post>(new List<Post> { 
                new Post { Status = PostStatus.Published, Path ="2013/04/10/some-other-post", Posted = new DateTime(2013,4,10), Author = new User{ Email = "" }, BlogId = 1 },
                new Post { 
                    Id = 1,
                    Status = PostStatus.Unpublished, 
                    Path ="2013/04/14/some-post", 
                    Posted = new DateTime(2013,4,14), 
                    Author = new User{ Email = "", FirstName = "Joe", LastName = "Bloggs" },
                    DraftBody = "asdf",
                    DraftTitle = "qwerty", 
                    BlogId = 1
                }
            }));

            PostController sut = new PostController(postRepo, null, _blogRepo, _mockHttpContext.Object);
            var result = (ViewResult)sut.Preview(1);

            Assert.IsNotNull(result);
            var model = result.Model as PostModel;
            Assert.IsNotNull(model);

            var md = new MarkdownDeep.Markdown();
            Assert.AreEqual("Joe Bloggs", model.Author.Name);
            Assert.AreEqual(md.Transform("asdf"), model.Body);
            Assert.AreEqual("qwerty", model.Title);
        }
开发者ID:stilldesign,项目名称:StaticVoid.Blog,代码行数:28,代码来源:PostControllerPreviewTests.cs

示例2: RunResourceTest

        public static void RunResourceTest(string resourceName)
        {
            string input = Utils.LoadTextResource(resourceName);
            string expected = Utils.LoadTextResource(System.IO.Path.ChangeExtension(resourceName, "html"));

            var md = new MarkdownDeep.Markdown();
            md.SafeMode = resourceName.IndexOf("(SafeMode)") >= 0;
            md.ExtraMode = resourceName.IndexOf("(ExtraMode)") >= 0;
            md.GitHubCodeBlocks = resourceName.IndexOf("(GitHubMode)") >= 0;
            md.DocNetMode = resourceName.IndexOf("(DocNetMode") >= 0;
            md.MarkdownInHtml = resourceName.IndexOf("(MarkdownInHtml)") >= 0;
            md.AutoHeadingIDs = resourceName.IndexOf("(AutoHeadingIDs)") >= 0;
            if(resourceName.IndexOf("(Titled)") >= 0)
            {
                md.HtmlClassTitledImages = "figure";
            }
            if(md.DocNetMode)
            {
                md.GitHubCodeBlocks = true;
            }

            string actual = md.Transform(input);
            string actual_clean = Utils.strip_redundant_whitespace(actual);
            string expected_clean = Utils.strip_redundant_whitespace(expected);

            string sep = new string('-', 30) + "\n";

            Console.WriteLine("Input:\n" + sep + input);
            Console.WriteLine("Actual:\n" + sep + actual);
            Console.WriteLine("Expected:\n" + sep + expected);

            Assert.AreEqual(expected_clean, actual_clean);
        }
开发者ID:FransBouma,项目名称:DocNet,代码行数:33,代码来源:Utils.cs

示例3: RunTestJS

        public static void RunTestJS(string input, bool SafeMode, bool ExtraMode, bool MarkdownInHtml, bool AutoHeadingIDs)
        {
            string normalized_input = input.Replace("\r\n", "\n").Replace("\r", "\n");

            // Work out the expected output using C# implementation
            var md = new MarkdownDeep.Markdown();
            md.SafeMode = SafeMode;
            md.ExtraMode = ExtraMode;
            md.MarkdownInHtml = MarkdownInHtml;
            md.AutoHeadingIDs = AutoHeadingIDs;
            string expected = md.Transform(normalized_input);

            // Transform using javascript implementation
            string actual = TransformUsingJS(input, SafeMode, ExtraMode, MarkdownInHtml, AutoHeadingIDs);

            actual = actual.Replace("\r", "");
            expected = expected.Replace("\r", "");

            string sep = new string('-', 30) + "\n";

            Console.WriteLine("Input:\n" + sep + input);
            Console.WriteLine("Actual:\n" + sep + actual);
            Console.WriteLine("Expected:\n" + sep + expected);

            // Check it
            Assert.AreEqual(expected, actual);
        }
开发者ID:FransBouma,项目名称:markdowndeep,代码行数:27,代码来源:Utils.cs

示例4: GenerateFeed

		private SyndicationFeed GenerateFeed()        
        {
            var currentBlog = this.CurrentBlog;

            var md = new MarkdownDeep.Markdown();
            List<SyndicationItem> posts = new List<SyndicationItem>();
            foreach (var post in _postRepository.FeedPosts(currentBlog.Id).OrderByDescending(p => p.Posted).Take(25).AsEnumerable())
            {
                var item = new SyndicationItem(post.Title, post.Body, new Uri(currentBlog.AuthoritiveUrl.TrimEnd('/') + "/" + post.Path.TrimStart('/')));

                item.Title = new TextSyndicationContent(post.Title);
                item.Content = new TextSyndicationContent(md.Transform(post.Body), TextSyndicationContentKind.Html);
                item.PublishDate = new DateTimeOffset(post.Posted);
                item.LastUpdatedTime = new DateTimeOffset(post.Posted);
                item.Id = post.PostGuid.ToString();
                                
                posts.Add(item);
            }


            return new SyndicationFeed("StaticVoid", "A blog on .Net", new Uri(currentBlog.AuthoritiveUrl), posts)
			{
				Language = "en-US",
                LastUpdatedTime = posts.Any() ? posts.Max(p=>p.LastUpdatedTime) : new DateTime(2012,12,21),
                Id = currentBlog.BlogGuid.ToString()
			};
		}
开发者ID:stilldesign,项目名称:StaticVoid.Blog,代码行数:27,代码来源:FeedController.cs

示例5: SetMessage

 private void SetMessage(string text)
 {
     var md = new MarkdownDeep.Markdown();
     md.ExtraMode = true;
     md.SafeMode = false;
     ViewBag.Message = md.Transform(text);
 }
开发者ID:moonavw,项目名称:testlab,代码行数:7,代码来源:WikiController.cs

示例6: renderPage

        private void renderPage(object sender, System.Timers.ElapsedEventArgs e)
        {
            DateTime lastWrite = File.GetLastWriteTime(fileName);
            if (lastWrite != latestWrite)
            {
                latestWrite = lastWrite;

                var md = new MarkdownDeep.Markdown();
                md.SafeMode = false;

                TextReader infile = new StreamReader(fileName);
                String input = infile.ReadToEnd();
                infile.Close();

                String output;
                if (jekyllMode)
                {
                    output = md.Transform(Regex.Replace(input, @"---[\p{IsBasicLatin}]+---\r", ""));
                }
                else
                {
                    output = md.Transform(input);
                }
                webTargetPage.DocumentText = output;
            }
        }
开发者ID:dHeinemann,项目名称:Mark-My-Words,代码行数:26,代码来源:frmMain.cs

示例7: FromMarkdown

 public static string FromMarkdown(this HtmlHelper helper, string markdown)
 {
     var md = new MarkdownDeep.Markdown();
     md.SafeMode = true;
     md.ExtraMode = true;
     return md.Transform(markdown);
 }
开发者ID:iloabn,项目名称:swetugg-web,代码行数:7,代码来源:MarkdownHelpers.cs

示例8: GetHtmlFromMarkdown

        public static string GetHtmlFromMarkdown(string markdownText)
        {
            var md = new MarkdownDeep.Markdown();
            md.ExtraMode = true;
            md.SafeMode = false;

            return md.Transform(markdownText);
        }
开发者ID:ramhog69,项目名称:OmahaMTG.Website,代码行数:8,代码来源:MarkdownService.cs

示例9: ParseMarkdown

        private static string ParseMarkdown(string markdown)
        {
            var md = new MarkdownDeep.Markdown();
            md.ExtraMode = true;
            md.SafeMode = false;

            return md.Transform(markdown);
        }
开发者ID:abinabrahamanchery,项目名称:mixerp,代码行数:8,代码来源:Release.cs

示例10: MarkdownTransform

        public static string MarkdownTransform(this HtmlHelper html, string paramToTransform)
        {
            var markdown = new MarkdownDeep.Markdown();
            markdown.SafeMode = false;
            markdown.ExtraMode = true;

            return markdown.Transform(paramToTransform);
        }
开发者ID:pavlove,项目名称:Blog,代码行数:8,代码来源:MarkdownDeepHelpers.cs

示例11: FormatMessage

        public static string FormatMessage(String originalMessage)
        {
            MarkdownDeep.Markdown m = new MarkdownDeep.Markdown();

            m.ExtraMode = true;
            m.SafeMode = true;

            return m.Transform(originalMessage);
        }
开发者ID:G-Octav,项目名称:whoaverse,代码行数:9,代码来源:Formatting.cs

示例12: GetPagesFromCache

 public static List<PostEntity> GetPagesFromCache(this ICacheService cacheService, IPost postRepository, string keyName, bool isMarkdown)
 {
     var markdown = new MarkdownDeep.Markdown{ ExtraMode = true };
     var pages = cacheService.Get(keyName, () => postRepository.GetPages());
     if (isMarkdown)
     {
         pages.ForEach(p => p.PostContent = markdown.Transform(p.PostContent));
     }
     return pages;
 }
开发者ID:rinckd,项目名称:sblog.net,代码行数:10,代码来源:CacheServiceFluentExtensions.cs

示例13: GetEvents

        public PagedSet<EventInfo> GetEvents(int skip, int take, bool includeExpired, bool includeRsvpCount, bool includeDeleted)
        {
            var posts = _context.Events
                .Where(w => w.PublishStartTime <= DateTime.Now || w.PublishStartTime == null || includeExpired)
                .Where(w => w.PublishEndTime >= DateTime.Now || w.PublishEndTime == null || includeExpired)
                .Where(w => includeDeleted || !w.IsDeleted)
                .OrderByDescending(o => o.PublishStartTime)
                .Include(cbu => cbu.CreatedByUser)
                .Include(g => g.Groups)
                
                .Select(s => s);

            int totalPosts = posts.Count();

            var md = new MarkdownDeep.Markdown();
            md.ExtraMode = true;
            md.SafeMode = false;

            var mappedPosts = posts.Skip(skip).Take(take).ToList()
                .Select(s =>
                   new EventInfo()
                    {
                        PublishStartTime = s.PublishStartTime,
                        Body = s.Body,
                        HtmlBody = md.Transform(s.Body),
                        HtmlBodySummary = md.Transform(s.Body.Length <= 500 ? s.Body : s.Body.Substring(0, 500).TrimEnd() + "...."),
                        CreatedByUserId = s.CreatedByUserId,
                        CreatedByUserName = GetUserName(s.CreatedByUser),
                        EventEndTime = (s as Event).EventEndTime,
                        EventStartTime = (s as Event).EventStartTime,
                        Id = s.Id,
                        Title = s.Title,
                        GroupTags = s.Groups.Select(g=> g.Id), 
                        PublishEndTime =  s.PublishEndTime,
                        IsDeleted = s.IsDeleted,
                        AvailableGroups = AvailableGroups,
                        VimeoId = (s as Event).VimeoId, 
                        TotalRsvpCount = includeRsvpCount ?  _context.Rsvps.Count(w => w.EventId == s.Id): 0
                        
                    });

            return new PagedSet<EventInfo>(totalPosts,skip, take,  mappedPosts);
        }
开发者ID:jeffcompuguy,项目名称:OmahaMTG.Website,代码行数:43,代码来源:EventManager.cs

示例14: Index

        public ActionResult Index()
        {
            // View the user editable content

            // Create and setup Markdown translator
            var md = new MarkdownDeep.Markdown { SafeMode = true, ExtraMode = true };

            // Transform the content and pass to the view
            ViewBag.Content = md.Transform(m_Content);
            return View();
        }
开发者ID:wwwlicious,项目名称:markdowndeep,代码行数:11,代码来源:MarkdownDeepController.cs

示例15: CreateElement

 protected override XElement CreateElement(CmsContext context, CmsPart part)
 {
     var md = new MarkdownDeep.Markdown
     {
         ExtraMode = true,
         SafeMode = false,
         NewWindowForExternalLinks = true,
         FormatCodeBlock = (markdown, s) => FormatCodeBlock(context, markdown, s)
     };
     return Parse(md.Transform(part.Value));
 }
开发者ID:Steinerd,项目名称:MicroCms,代码行数:11,代码来源:MarkdownCmsRenderService.cs


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