fixes #677. CommonMark.NET replaced with Markdig.

Table rendering is now enabled.
pull/705/head
Alper Ebicoglu 6 years ago
parent e8259d1517
commit 1ec88daed8

@ -0,0 +1,7 @@
namespace Volo.Docs.Markdown
{
public interface IMarkdownConverter
{
string ConvertToHtml(string markdown);
}
}

@ -0,0 +1,27 @@
using System.Text;
using Markdig;
using Volo.Abp.DependencyInjection;
namespace Volo.Docs.Markdown
{
public class MarkDigMarkdownConverter : IMarkdownConverter, ISingletonDependency
{
readonly MarkdownPipeline _markdownPipeline;
public MarkDigMarkdownConverter()
{
_markdownPipeline = new MarkdownPipelineBuilder()
.UseAutoLinks()
.UseBootstrap()
.UseGridTables()
.UsePipeTables()
.Build();
}
public virtual string ConvertToHtml(string markdown)
{
return Markdig.Markdown.ToHtml(Encoding.UTF8.GetString(Encoding.Default.GetBytes(markdown)),
_markdownPipeline);
}
}
}

@ -1,7 +1,5 @@
using System;
using System.Text;
using System.Text.RegularExpressions;
using CommonMark;
using Volo.Abp.DependencyInjection;
using Volo.Docs.Documents;
using Volo.Docs.HtmlConverting;
@ -14,10 +12,17 @@ namespace Volo.Docs.Markdown
{
public const string Type = "md";
private readonly IMarkdownConverter _markdownConverter;
public MarkdownDocumentToHtmlConverter(IMarkdownConverter markdownConverter)
{
_markdownConverter = markdownConverter;
}
private const string MdLinkFormat = "[{0}](/documents/{1}/{2}{3}/{4})";
private const string MarkdownLinkRegExp = @"\[(.*)\]\((.*\.md)\)";
private const string AnchorLinkRegExp = @"<a[^>]+href=\""(.*?)\""[^>]*>(.*)?</a>";
public virtual string Convert(ProjectDto project, DocumentWithDetailsDto document, string version)
{
if (document.Content.IsNullOrEmpty())
@ -32,9 +37,9 @@ namespace Volo.Docs.Markdown
document.LocalDirectory
);
return CommonMarkConverter.Convert(Encoding.UTF8.GetString(Encoding.Default.GetBytes(content)));
return _markdownConverter.ConvertToHtml(content);
}
protected virtual string NormalizeLinks(
string content,
string projectShortName,

@ -225,6 +225,24 @@
margin: 15px 0 25px;
box-shadow: 0 0 45px #f8f9fa;
border-radius: 6px; }
.docs-page .docs-content article.docs-body table {
display: block;
overflow: auto;
width: 100%; }
.docs-page .docs-content article.docs-body table thead tr {
border-bottom: 2px inset; }
.docs-page .docs-content article.docs-body table th {
font-weight: 600; }
.docs-page .docs-content article.docs-body table td, .docs-page .docs-content article.docs-body table th {
border: 1px solid #dfe2e5;
padding: 6px 13px; }
.docs-page .docs-content article.docs-body table tr {
background-color: #fff;
border-top: 1px solid #c6cbd1; }
.docs-page .docs-content article.docs-body table tr:nth-child(2n) {
background-color: #f6f8fa; }
.docs-page .docs-content article.docs-body table img {
background-color: initial; }
.docs-page .docs-page-index {
min-height: 100vh; }
.docs-page .docs-page-index #scroll-index {

File diff suppressed because one or more lines are too long

@ -370,6 +370,41 @@ body {
box-shadow: 0 0 45px #f8f9fa;
border-radius: 6px;
}
table {
display: block;
overflow: auto;
width: 100%;
thead {
tr {
border-bottom: 2px inset;
}
}
th {
font-weight: 600
}
td, th {
border: 1px solid #dfe2e5;
padding: 6px 13px
}
tr {
background-color: #fff;
border-top: 1px solid #c6cbd1
}
tr:nth-child(2n) {
background-color: #f6f8fa
}
img {
background-color: initial
}
}
}
}
@ -833,7 +868,7 @@ div.code-toolbar > .toolbar a {
margin-left: -1rem;
}
}
.section-with-logos img {
margin: 15px;
opacity: 1;
@ -851,5 +886,4 @@ div.code-toolbar > .toolbar a {
.mb-5, .my-5 {
margin-bottom: 2rem !important;
}
}
}

@ -18,7 +18,7 @@
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.AspNetCore.Mvc.UI.Packages\Volo.Abp.AspNetCore.Mvc.UI.Packages.csproj" />
<ProjectReference Include="..\Volo.Docs.HttpApi\Volo.Docs.HttpApi.csproj" />
<PackageReference Include="CommonMark.NET" Version="0.15.1" />
<PackageReference Include="Markdig.Signed" Version="0.15.6" />
</ItemGroup>
@ -40,10 +40,6 @@
<Content Remove="Properties\launchSettings.json" />
<Content Remove="compilerconfig.json" />
<Content Remove="compilerconfig.json.defaults" />
<None Remove="Pages\Documents\Project\bootstrap-toc.js" />
<None Remove="Pages\Documents\Project\index - Copy.css" />
<None Remove="Pages\Documents\Project\index - Copy.min.css" />
<None Remove="Pages\Documents\Project\vs.js" />
<None Include="compilerconfig.json" />
<None Include="Properties\launchSettings.json" />
</ItemGroup>

Loading…
Cancel
Save