Home

Awesome

<!-- GENERATED FILE - DO NOT EDIT This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets). Source File: /README.source.md To change this file edit the source file and then run MarkdownSnippets. -->

Meet ReverseMarkdown

Build status NuGet Version

ReverseMarkdown is a Html to Markdown converter library in C#. Conversion is very reliable since HtmlAgilityPack (HAP) library is used for traversing the Html DOM.

If you have used and benefitted from this library. Please feel free to buy me a coffee!<br> <a href="https://github.com/sponsors/mysticmind" target="_blank"><img height="30" style="border:0px;height:36px;" src="https://img.shields.io/static/v1?label=GitHub Sponsor&message=%E2%9D%A4&logo=GitHub" border="0" alt="GitHub Sponsor" /></a> <!--<a href="https://ko-fi.com/babuannamalai" target="_blank"><img height="36" style="border:0px;height:36px;" src="https://cdn.ko-fi.com/cdn/kofi4.png?v=3" border="0" alt="Buy Me a Coffee at ko-fi.com" /></a> <a href="https://www.buymeacoffee.com/babuannamalai" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="36" width="174"></a>-->

Usage

Install the package from NuGet using Install-Package ReverseMarkdown or clone the repository and built it yourself.

<!-- snippet: Usage -->

<a id='snippet-usage'></a>

var converter = new ReverseMarkdown.Converter();

string html = "This a sample <strong>paragraph</strong> from <a href=\"http://test.com\">my site</a>";

string result = converter.Convert(html);

<sup><a href='/src/ReverseMarkdown.Test/Snippets.cs#L11-L19' title='Snippet source file'>snippet source</a> | <a href='#snippet-usage' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Will result in:

<!-- snippet: Snippets.Usage.verified.txt -->

<a id='snippet-Snippets.Usage.verified.txt'></a>

This a sample **paragraph** from [my site](http://test.com)

<sup><a href='/src/ReverseMarkdown.Test/Snippets.Usage.verified.txt#L1-L1' title='Snippet source file'>snippet source</a> | <a href='#snippet-Snippets.Usage.verified.txt' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

The conversion can be customized:

<!-- snippet: UsageWithConfig -->

<a id='snippet-usagewithconfig'></a>

var config = new ReverseMarkdown.Config
{
    // Include the unknown tag completely in the result (default as well)
    UnknownTags = Config.UnknownTagsOption.PassThrough,
    // generate GitHub flavoured markdown, supported for BR, PRE and table tags
    GithubFlavored = true,
    // will ignore all comments
    RemoveComments = true,
    // remove markdown output for links where appropriate
    SmartHrefHandling = true
};

var converter = new ReverseMarkdown.Converter(config);

<sup><a href='/src/ReverseMarkdown.Test/Snippets.cs#L27-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-usagewithconfig' title='Start of snippet'>anchor</a></sup>

<!-- endSnippet -->

Configuration options

Note that UnknownTags config has been changed to an enumeration in v2.0.0 (breaking change)

Features

Acknowledgements

This library's initial implementation ideas were from the Ruby based Html to Markdown converter xijo/reverse_markdown.

Copyright

Copyright © Babu Annamalai

License

ReverseMarkdown is licensed under MIT. Refer to License file for more information.