mirror of https://github.com/abpframework/abp.git
11 changed files with 87 additions and 53 deletions
@ -1,27 +0,0 @@ |
|||
using System; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Docs.Formatting |
|||
{ |
|||
public class DocumentConverterFactory : IDocumentConverterFactory, ITransientDependency |
|||
{ |
|||
private readonly IServiceProvider _serviceProvider; |
|||
|
|||
public DocumentConverterFactory(IServiceProvider serviceProvider) |
|||
{ |
|||
_serviceProvider = serviceProvider; |
|||
} |
|||
|
|||
public IDocumentConverter Create(string format) |
|||
{ |
|||
switch (format.ToLowerInvariant()) |
|||
{ |
|||
case MarkdownDocumentConverter.Type: |
|||
return _serviceProvider.GetRequiredService<MarkdownDocumentConverter>(); |
|||
default: |
|||
throw new ApplicationException($"Undefined document formatting: {format}"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +0,0 @@ |
|||
namespace Volo.Docs.Formatting |
|||
{ |
|||
public interface IDocumentConverter |
|||
{ |
|||
string Convert(string content); |
|||
|
|||
string NormalizeLinks(string content, string projectShortName, string version, string documentLocalDirectory); |
|||
} |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
namespace Volo.Docs.Formatting |
|||
{ |
|||
public interface IDocumentConverterFactory |
|||
{ |
|||
IDocumentConverter Create(string format); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using Volo.Abp.DependencyInjection; |
|||
|
|||
namespace Volo.Docs.HtmlConverting |
|||
{ |
|||
public class DocumentToHtmlConverterFactory : IDocumentToHtmlConverterFactory, ITransientDependency |
|||
{ |
|||
protected DocumentToHtmlConverterOptions Options { get; } |
|||
protected IServiceProvider ServiceProvider { get; } |
|||
|
|||
public DocumentToHtmlConverterFactory( |
|||
IServiceProvider serviceProvider, |
|||
IOptions<DocumentToHtmlConverterOptions> options) |
|||
{ |
|||
ServiceProvider = serviceProvider; |
|||
Options = options.Value; |
|||
} |
|||
|
|||
public virtual IDocumentToHtmlConverter Create(string format) |
|||
{ |
|||
var serviceType = Options.Converters.GetOrDefault(format); |
|||
if (serviceType == null) |
|||
{ |
|||
throw new ApplicationException($"Unknown document format: {format}"); |
|||
} |
|||
|
|||
return (IDocumentToHtmlConverter)ServiceProvider.GetRequiredService(serviceType); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Volo.Docs.HtmlConverting |
|||
{ |
|||
public class DocumentToHtmlConverterOptions |
|||
{ |
|||
public Dictionary<string, Type> Converters { get; set; } |
|||
|
|||
public DocumentToHtmlConverterOptions() |
|||
{ |
|||
Converters = new Dictionary<string, Type>(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
namespace Volo.Docs.HtmlConverting |
|||
{ |
|||
public interface IDocumentToHtmlConverter |
|||
{ |
|||
string Convert(string content); |
|||
|
|||
string NormalizeLinks( |
|||
string content, |
|||
string projectShortName, |
|||
string version, |
|||
string documentLocalDirectory |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace Volo.Docs.HtmlConverting |
|||
{ |
|||
public interface IDocumentToHtmlConverterFactory |
|||
{ |
|||
IDocumentToHtmlConverter Create(string format); |
|||
} |
|||
} |
|||
@ -1,13 +1,14 @@ |
|||
using CommonMark; |
|||
using System; |
|||
using System; |
|||
using System.Text; |
|||
using System.Text.RegularExpressions; |
|||
using CommonMark; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Docs.HtmlConverting; |
|||
using Volo.Docs.Utils; |
|||
|
|||
namespace Volo.Docs.Formatting |
|||
namespace Volo.Docs.Markdown |
|||
{ |
|||
public class MarkdownDocumentConverter : IDocumentConverter, ITransientDependency |
|||
public class MarkdownDocumentToHtmlConverter : IDocumentToHtmlConverter, ITransientDependency |
|||
{ |
|||
public const string Type = "md"; |
|||
|
|||
Loading…
Reference in new issue