本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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()
};
}
示例5: SetMessage
private void SetMessage(string text)
{
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
ViewBag.Message = md.Transform(text);
}
示例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;
}
}
示例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);
}
示例8: GetHtmlFromMarkdown
public static string GetHtmlFromMarkdown(string markdownText)
{
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
return md.Transform(markdownText);
}
示例9: ParseMarkdown
private static string ParseMarkdown(string markdown)
{
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
return md.Transform(markdown);
}
示例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);
}
示例11: FormatMessage
public static string FormatMessage(String originalMessage)
{
MarkdownDeep.Markdown m = new MarkdownDeep.Markdown();
m.ExtraMode = true;
m.SafeMode = true;
return m.Transform(originalMessage);
}
示例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;
}
示例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);
}
示例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();
}
示例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));
}