Allows consumers to easily convert strings to Markdown using the IMarkdownConverter
interface.
This library contains implementations of
ForEvolve.Markdown.Abstractions
.
The center piece is the IMarkdownConverter
interface.
public interface IMarkdownConverter
{
string ConvertToHtml(string markdown);
}
Right now, the project contains only a wrapper around lunet-io/markdig
, however, in the future, multiple implementations could be created.
Why use this instead of Markdig
and why did I created this?
Simple! It creates an abstraction between my code (consumer) and Markdig
(the library doing the actual convertion to markdown).
This way, if I want to use another library later, the only place that needs to be updated is the composition root of the project.
[...] and of course a new implementation of the
IMarkdownConverter
interface must be created by someone.
You can load this package directly or use the ForEvolve metapackage. As of now, they are only available on the ForEvove MyGet feed.
ForEvolve NuGet V3 feed URL packages source. See the Table of content project for more info.
Register the services in the ConfigureServices
method by calling the AddMarkdig()
extension method.
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddMarkdig();
//...
}
That's it! Now you can inject an IMarkdownConverter
service in your classes.
If you want more control over your markdown covertion, you can configure the pipeline when calling the AddMarkdig()
extension method.
By default, the HTML parsing is disabled.
The
DisableHtml()
method is called on theMarkdownPipelineBuilder
.
services.AddMarkdig(options => options.DisableHtml = false);
The MarkdownPipelineBuilder
is exposed in the options; you can leverage it as follow.
services.AddMarkdig(options =>
{
options.Configure = builder =>
{
// Add your customization here...
builder.UseAdvancedExtensions(); // example
};
});