本文整理汇总了C#中MarkdownDeep.Markdown类的典型用法代码示例。如果您正苦于以下问题:C# MarkdownDeep.Markdown类的具体用法?C# MarkdownDeep.Markdown怎么用?C# MarkdownDeep.Markdown使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MarkdownDeep.Markdown类属于命名空间,在下文中一共展示了MarkdownDeep.Markdown类的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: SetMessage
private void SetMessage(string text)
{
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
ViewBag.Message = md.Transform(text);
}
示例3: 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;
}
}
示例4: 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);
}
示例5: 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()
};
}
示例6: Linkify
public void Linkify(string text, Action<string> onSuccess)
{
text = Regex.Replace(text, @"(http\://|https\://|www.)\S*", match => {
if (match.Index != 0)
{
var previousChar = text[match.Index - 1];
if (!char.IsWhiteSpace(previousChar))
return match.Value;
}
var value = match.Value;
var path = new UriBuilder(value).Uri.AbsolutePath;
if (match.Groups[1].Value == "www.")
value = "http://" + value;
return path.EndsWith("jpg") || path.EndsWith("gif") || path.EndsWith("png")
? "![Inline Image](" + value + ")"
: "[" + value + "](" + value + ")";
});
text = new MarkdownDeep.Markdown {
ExtraMode = true,
NewWindowForExternalLinks = true,
NewWindowForLocalLinks = true,
}.Transform(text);
text = text.Replace("\n", "");
text = text.Replace(@"\", @"\\");
onSuccess(text);
}
示例7: 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);
}
示例8: ViewFeedback
//
// GET: /Project/Feedback/projectid
//
// Updated to v2.0 w/ audit trails
public ActionResult ViewFeedback(int projectid = 0)
{
Mapper.CreateMap<ProjectVersion, ProjectView>();
Mapper.CreateMap<Project, ProjectView>();
Project project = db.Projects.Find(projectid);
ProjectView feedbackProject = Mapper.Map<Project, ProjectView>(project);
Mapper.Map(project.CurrentVersion, feedbackProject);
feedbackProject.Feedbacks = db.Feedbacks.Where(b => b.owner.ProjectId.Equals(projectid)).ToList();
//takes the comment and turns it into markedup html
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
foreach (var feedback in feedbackProject.Feedbacks)
{
string MarkedUp = md.Transform(feedback.Comment);
feedback.Comment = MarkedUp;
}
return View(feedbackProject);
}
示例9: 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);
}
示例10: SetUp
public void SetUp()
{
markdown = new MarkdownDeep.Markdown();
message1 = new MessageViewModel { AuthorName = "Dianne", ID = 1, RoomID = 12345, Text = "Test!" };
mockRoomViewModelReader = new Mock<IRoomViewModelReader>();
var roomMessages = new[] { message1 };
mockRoomViewModelReader.Setup(reader => reader.GetRoomMessages(It.IsAny<int>())).Returns(roomMessages);
}
示例11: ParseMarkdown
private static string ParseMarkdown(string markdown)
{
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
return md.Transform(markdown);
}
示例12: 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);
}
示例13: GetHtmlFromMarkdown
public static string GetHtmlFromMarkdown(string markdownText)
{
var md = new MarkdownDeep.Markdown();
md.ExtraMode = true;
md.SafeMode = false;
return md.Transform(markdownText);
}
示例14: FormatMessage
public static string FormatMessage(String originalMessage)
{
MarkdownDeep.Markdown m = new MarkdownDeep.Markdown();
m.ExtraMode = true;
m.SafeMode = true;
return m.Transform(originalMessage);
}
示例15: MarkdownConverter
public MarkdownConverter()
{
_markdown = new MarkdownDeep.Markdown
{
ExtraMode = true,
HtmlClassTitledImages = "Figure",
FormatCodeBlock = FormatCodeBlock,
};
}