Add support for Markdown with syntax highlighting
This commit is contained in:
parent
32eef104fb
commit
19818ef69e
5 changed files with 46 additions and 23 deletions
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using Markdig;
|
||||
using Markdig.SyntaxHighlighting;
|
||||
using Website.Models;
|
||||
|
||||
namespace Website.ViewModels
|
||||
|
@ -8,12 +10,21 @@ namespace Website.ViewModels
|
|||
public BlogPostViewModel(BlogPost blogPost)
|
||||
{
|
||||
Title = blogPost.Title;
|
||||
Content = blogPost.Content;
|
||||
Content = Markdown.ToHtml(blogPost.Content).Trim();
|
||||
Timestamp = blogPost.Timestamp;
|
||||
Url = blogPost.Url;
|
||||
|
||||
Content = Markdown.ToHtml(blogPost.Content, GetPipeline()).Trim();
|
||||
}
|
||||
|
||||
public string Title { get; private set; }
|
||||
private MarkdownPipeline GetPipeline()=>new MarkdownPipelineBuilder()
|
||||
//.UseAdvancedExtensions()
|
||||
.UseAutoLinks()
|
||||
.UseSoftlineBreakAsHardlineBreak()
|
||||
.UseSyntaxHighlighting()
|
||||
.Build();
|
||||
|
||||
public string Title { get; private set; }
|
||||
public string Content { get; private set; }
|
||||
public DateTime Timestamp { get; private set; }
|
||||
public string Url { get; private set; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue