Skip to content

Commit b30e5ef

Browse files
committed
Markdown to use advanced features
1 parent a16a459 commit b30e5ef

File tree

6 files changed

+26
-17
lines changed

6 files changed

+26
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## What is Blogifier
22

3-
Blogifier is simple, beautiful, light-weight open source blog written in .NET Core. This cross-platform, highly extendable and customizable web application brings all the best blogging features in small, portable package.
3+
Blogifier is multi-user, lightweight blog written in .NET Core with Angular front-end. For programmers, it is easy maintain and extend and for designers, it is simple to customize using familiar tools.
44

55
[![Build Status](https://dev.azure.com/rtur/Blogifier/_apis/build/status/blogifierdotnet.Blogifier)](https://dev.azure.com/rtur/Blogifier/_build/latest?definitionId=3)
66

src/App/Controllers/BlogController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Core.Data;
1+
using Core;
2+
using Core.Data;
23
using Core.Services;
3-
using Markdig;
44
using Microsoft.AspNetCore.Authorization;
55
using Microsoft.AspNetCore.Identity;
66
using Microsoft.AspNetCore.Mvc;
@@ -44,7 +44,7 @@ public async Task Rss(string type)
4444

4545
foreach (var post in posts)
4646
{
47-
post.Description = Markdown.ToHtml(post.Description);
47+
post.Description = post.Description.MdToHtml();
4848
await writer.Write(post);
4949
}
5050
}

src/Core/Api/NotificationsController.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Core.Data.Models;
33
using Core.Helpers;
44
using Core.Services;
5-
using Markdig;
65
using Microsoft.AspNetCore.Cors;
76
using Microsoft.AspNetCore.Http;
87
using Microsoft.AspNetCore.Mvc;
@@ -142,7 +141,7 @@ public async Task<NotificationModel> GetNotifications(string type, int page = 1)
142141
items = await _data.Notifications.GetList(n => n.AlertType == noteType && n.Active == true, pager);
143142
foreach (var item in items)
144143
{
145-
item.Content = Markdown.ToHtml(item.Content);
144+
item.Content = item.Content.MdToHtml();
146145
}
147146
}
148147

src/Core/Api/PostsController.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using Core.Data;
22
using Core.Helpers;
33
using Core.Services;
4-
using Markdig;
54
using Microsoft.AspNetCore.Authorization;
65
using Microsoft.AspNetCore.Cors;
76
using Microsoft.AspNetCore.Http;
@@ -57,8 +56,8 @@ public async Task<ActionResult<PageListModel>> Search(
5756
{
5857
foreach (var p in results)
5958
{
60-
p.Description = Markdown.ToHtml(p.Description);
61-
p.Content = Markdown.ToHtml(p.Content);
59+
p.Description = p.Description.MdToHtml();
60+
p.Content = p.Content.MdToHtml();
6261
}
6362
}
6463

@@ -101,8 +100,8 @@ public async Task<ActionResult<PageListModel>> Get(
101100
{
102101
foreach (var p in results)
103102
{
104-
p.Description = Markdown.ToHtml(p.Description);
105-
p.Content = Markdown.ToHtml(p.Content);
103+
p.Description = p.Description.MdToHtml();
104+
p.Content = p.Content.MdToHtml();
106105
}
107106
}
108107

@@ -129,8 +128,8 @@ public async Task<PostItem> GetPost(int id, [FromQuery]string format = "html")
129128
var post = await _data.BlogPosts.GetItem(p => p.Id == id, !User.Identity.IsAuthenticated);
130129
if (format.ToUpper() == "HTML")
131130
{
132-
post.Description = Markdown.ToHtml(post.Description);
133-
post.Content = Markdown.ToHtml(post.Content);
131+
post.Description = post.Description.MdToHtml();
132+
post.Content = post.Content.MdToHtml();
134133
}
135134
return post;
136135
}
@@ -170,8 +169,8 @@ public async Task<PostModel> GetBySlug(string slug, [FromQuery]string format = "
170169

171170
if (format.ToUpper() == "HTML")
172171
{
173-
model.Post.Description = Markdown.ToHtml(model.Post.Description);
174-
model.Post.Content = Markdown.ToHtml(model.Post.Content);
172+
model.Post.Description = model.Post.Description.MdToHtml();
173+
model.Post.Content = model.Post.Content.MdToHtml();
175174
}
176175
return model;
177176
}

src/Core/Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<Version>2.4.1.1</Version>
5+
<Version>2.4.1.2</Version>
66
</PropertyGroup>
77

88
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

src/Core/Extensions/StringExtensions.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using Markdig;
2+
using System;
23
using System.Globalization;
34
using System.Linq;
45
using System.Text;
@@ -72,6 +73,16 @@ public static string ToDescription(this string str)
7273
return str.Length > 300 ? str.Substring(0, 300) : str;
7374
}
7475

76+
public static string MdToHtml(this string str)
77+
{
78+
var mpl = new MarkdownPipelineBuilder()
79+
.UsePipeTables()
80+
.UseAdvancedExtensions()
81+
.Build();
82+
83+
return Markdown.ToHtml(str, mpl);
84+
}
85+
7586
public static bool Contains(this string source, string toCheck, StringComparison comp)
7687
{
7788
return source.IndexOf(toCheck, comp) >= 0;

0 commit comments

Comments
 (0)