Moved markdown parsing to separate function
This commit is contained in:
parent
68155ce15a
commit
3d966ac2dd
|
@ -6,6 +6,7 @@
|
|||
@using Markdig
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Identity
|
||||
@using Wave.Utilities
|
||||
|
||||
@attribute [Authorize(Policy = "ArticleEditPermissions")]
|
||||
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
||||
|
@ -156,12 +157,7 @@
|
|||
}
|
||||
article.LastModified = DateTimeOffset.UtcNow;
|
||||
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.UsePipeTables()
|
||||
.UseEmphasisExtras()
|
||||
.DisableHtml()
|
||||
.Build();
|
||||
article.BodyHtml = Markdown.ToHtml(article.Body, pipeline);
|
||||
article.BodyHtml = MarkdownUtilities.Parse(article.Body);
|
||||
|
||||
await context.SaveChangesAsync();
|
||||
if (article.Status >= ArticleStatus.Published && article.PublishDate <= DateTimeOffset.UtcNow) {
|
||||
|
|
15
Wave/Utilities/MarkdownUtilities.cs
Normal file
15
Wave/Utilities/MarkdownUtilities.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using Markdig;
|
||||
using Wave.Data;
|
||||
|
||||
namespace Wave.Utilities;
|
||||
|
||||
public static class MarkdownUtilities {
|
||||
public static string Parse(string markdown) {
|
||||
var pipeline = new MarkdownPipelineBuilder()
|
||||
.UsePipeTables()
|
||||
.UseEmphasisExtras()
|
||||
.DisableHtml()
|
||||
.Build();
|
||||
return Markdown.ToHtml(markdown, pipeline);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue