Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/MarkdownViewEngine/MarkdownPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using System;
using System.IO;
using System.Linq;
Expand All @@ -13,10 +14,13 @@ namespace MarkdownViewEngine
public class MarkdownPage : IMarkdownPage
{
private readonly IFileProvider _contentRootFileProvider;
private readonly MarkdownViewEngineOptions _options;

public MarkdownPage(IFileProvider contentRootFileProvider)
public MarkdownPage(IFileProvider contentRootFileProvider,
MarkdownViewEngineOptions options)
{
_contentRootFileProvider = contentRootFileProvider;
_options = options;
}

public IHtmlContent BodyContent { get; set; }
Expand Down Expand Up @@ -61,7 +65,7 @@ public async Task ExecuteAsync()
markdown = content;
}

var html = CommonMarkConverter.Convert(markdown);
var html = CommonMarkConverter.Convert(markdown, _options.MarkdownSettings);
BodyContent = new HtmlString(html);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/MarkdownViewEngine/MarkdownViewEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private ViewEngineResult LocatePageFromViewLocations(
var fileInfo = _contentRootFileProvider.GetFileInfo(view);
if (fileInfo.Exists)
{
var page = new MarkdownPage(_contentRootFileProvider)
var page = new MarkdownPage(_contentRootFileProvider, _options)
{
Path = view
};
Expand All @@ -130,7 +130,7 @@ private ViewEngineResult LocatePageFromPath(string executingFilePath, string pag
return ViewEngineResult.NotFound(applicationRelativePath, Enumerable.Empty<string>());
}

var page = new MarkdownPage(_contentRootFileProvider)
var page = new MarkdownPage(_contentRootFileProvider, _options)
{
Path = applicationRelativePath
};
Expand Down Expand Up @@ -188,7 +188,7 @@ private IMarkdownPage GetViewStartPage()
var fileInfo = _contentRootFileProvider.GetFileInfo(view);
if (fileInfo.Exists)
{
page = new MarkdownPage(_contentRootFileProvider)
page = new MarkdownPage(_contentRootFileProvider, _options)
{
Path = view
};
Expand Down
5 changes: 4 additions & 1 deletion src/MarkdownViewEngine/MarkdownViewEngineOptions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System.Collections.Generic;
using CommonMark;
using System.Collections.Generic;

namespace MarkdownViewEngine
{
public class MarkdownViewEngineOptions
{
public IList<string> ViewLocationFormats { get; } = new List<string>();

public CommonMarkSettings MarkdownSettings { get; } = CommonMarkSettings.Default.Clone();
}
}