using System.Globalization;
using System.Text.RegularExpressions;
public static void Main()
string sampleMD= "h1. You can edit this demo text\\!\n\nh2. How to use the editor:\n\nPaste your documents in the visual editor on the left or your HTML code in the source editor in the right. \nEdit any of the two areas and see the other changing in real time. \n\nClick the *Clean* button to clean your source code.\n\nh2. Some useful features:\n\n# Interactive source editor\n# HTML Cleaning\n# Word to HTML conversion\n# Find and Replace\n# Lorem-Ipsum generator\n# Table to DIV conversion\n\n!https://html-online.com/img/6-table-div-html.png|thumbnail!\n\n!https://html-online.com/img/05-gibberish.png|thumbnail!\n\n!https://html-online.com/img/04-replace.png|thumbnail!\n\n!https://html-online.com/img/03-docs-to-html.png|thumbnail!\n\n!https://html-online.com/img/02-html-clean.png|thumbnail!\n\n!https://html-online.com/img/01-interactive-connection.png|thumbnail!\n\n \n\nh2. Cleaning options:\n\n|Name of the feature|Example|Default|\n|Remove tag attributes|(except img-src and a-href)| |\n|Remove inline styles|You +*should never*+ use inline styles\\!|*x*|\n|Remove classes and IDs|Use classes to *style everything*.|*x*|\n|Remove all tags|This leaves only the plain text.| |\n|Remove successive s|Never use non-breaking spaces to set margins.|*x*|\n|Remove empty tags|Empty tags should go\\!| |\n|Remove tags with one |This makes no sense\\!|*x*|\n|Remove span tags|Span tags with all styles|*x*|\n|Remove images|I am an image:| |\n|Remove links|[This is a link.|https://html-online.com/]| |\n|Remove tables|Takes everything out of the table.| |\n|Replace table tags with structured divs|This text is inside a table.| |\n|Remove comments|This is only visible in the source editor|*x*|\n|Encode special characters|♥ *☺ ★* ><|*x*|\n|Set new lines and text indents|Organize the tags in a nice tree view.| |";
string sampleMD2= "# You can edit this demo text!\n ## How to use the editor:\n\nPaste your documents in the visual editor on the left or your HTML code in the source editor in the right.\n Edit any of the two areas and see the other changing in real time.\n\nClick the Clean button to clean your source code.\n\n## Some useful features:\n\n1. Interactive source editor\n2. HTML Cleaning\n3. Word to HTML conversion\n4. Find and Replace\n5. Lorem-Ipsum generator\n6. Table to DIV conversion\n\n\n\n\n## Cleaning options:\n\n\n| Name of the feature | Example | Default |\n| --- | --- | --- |\n| Remove tag attributes | (except **img**-*src* and **a**-*href*) | |\n| Remove inline styles | You **should never** use inline styles! | **x** |\n| Remove classes and IDs | Use classes to **style everything**. | **x** |\n| Remove all tags | This leaves **only the plain** *text*.  | |\n| Remove successive s | Never use non-breaking spaces to set margins. | **x** |\n| Remove empty tags | Empty tags should go! | |\n| Remove tags with one | This makes no sense! | **x** |\n| Remove span tags | Span tags with all styles | **x** |\n| Remove images | I am an image:  | |\n| Remove links | [This is](https://html-online.com) a link. | |\n| Remove tables | Takes everything out of the table. | |\n| Replace table tags with structured divs | This text is inside a table. | |\n| Remove comments | This is only visible in the source editor | **x** |\n| Encode special characters | ♥ **☺ ★** >< | **x** |\n| Set new lines and text indents | Organize the tags in a nice tree view. | |\n\n\n** **\n\n**Save this link into your bookmarks and share it with your friends. It is all FREE! ** \n**Enjoy!**\n\n** **\n\n";
string sampleMD3= "h1. You can edit this demo text\\!\n\nh2. How to use the editor:\n\nPaste your documents in the visual editor on the left or your HTML code in the source editor in the right. \nEdit any of the two areas and see the other changing in real time. \n\nClick the *Clean* button to clean your source code.\n\nh2. Some useful features:\n\n!https://html-online.com/img/01-interactive-connection.png|alt=\"interactive connection\"!\n\n!https://html-online.com/img/02-html-clean.png|alt=\"html cleaner\"!\n\n!https://html-online.com/img/03-docs-to-html.png|alt=\"Word to html\"!\n\n!https://html-online.com/img/04-replace.png|alt=\"replace text\"!\n\n!https://html-online.com/img/05-gibberish.png|alt=\"gibberish\"!\n\n!https://html-online.com/img/6-table-div-html.png|alt=\"html table div\"!\n\n# Interactive source editor\n# HTML Cleaning\n# Word to HTML conversion\n# Find and Replace\n# Lorem-Ipsum generator\n# Table to DIV conversion";
string sampleHTML = @"<h1 style=\'color: #5e9ca0;\'>You can edit <span style=\'color: #2b2301;\'>this demo</span> text!</h1><h2 style=\'color: #2e6c80;\'>How to use the editor:</h2><p>Paste your documents in the visual editor on the left or your HTML code in the source editor in the right. <br/>Edit any of the two areas and see the other changing in real time. </p><p>Click the <span style=\'background-color: #2b2301; color: #fff; display: inline-block; padding: 3px 10px; font-weight: bold; border-radius: 5px;\'>Clean</span> button to clean your source code.</p><h2 style=\'color: #2e6c80;\'>Some useful features:</h2><ol style=\'list-style: none; font-size: 14px; line-height: 32px; font-weight: bold;\'><li style=\'clear: both;\'><img style=\'float: left;\' src=\'https://html-online.com/img/01-interactive-connection.png' alt=\'interactive connection' width=\'45'/> Interactive source editor</li><li style=\'clear: both;\'><img style=\'float: left;\' src=\'https://html-online.com/img/02-html-clean.png' alt=\'html cleaner' width=\'45'/> HTML Cleaning</li><li style=\'clear: both;\'><img style=\'float: left;\' src=\'https://html-online.com/img/03-docs-to-html.png' alt=\'Word to html' width=\'45'/> Word to HTML conversion</li><li style=\'clear: both;\'><img style=\'float: left;\' src=\'https://html-online.com/img/04-replace.png' alt=\'replace text' width=\'45'/> Find and Replace</li><li style=\'clear: both;\'><img style=\'float: left;\' src=\'https://html-online.com/img/05-gibberish.png' alt=\'gibberish' width=\'45'/> Lorem-Ipsum generator</li><li style=\'clear: both;\'><img style=\'float: left;\' src=\'https://html-online.com/img/6-table-div-html.png' alt=\'html table div' width=\'45'/> Table to DIV conversion</li></ol><p> </p><h2 style=\'color: #2e6c80;\'>Cleaning options:</h2><table class=\'editorDemoTable\'><thead><tr><td>Name of the feature</td><td>Example</td><td>Default</td></tr></thead><tbody><tr><td>Remove tag attributes</td><td><img style=\'margin: 1px 15px;\' src=\'images/smiley.png' alt=\'laughing' width=\'40' height=\'16'/> (except <strong>img</strong>-<em>src</em> and <strong>a</strong>-<em>href</em>)</td><td> </td></tr><tr><td>Remove inline styles</td><td><span style=\'color: green; font-size: 13px;\'>You <strong style=\'color: blue; text-decoration: underline;\'>should never</strong> use inline styles!</span></td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Remove classes and IDs</td><td><span id=\'demoId\'>Use classes to <strong class=\'demoClass\'>style everything</strong>.</span></td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Remove all tags</td><td>This leaves <strong style=\'color: blue;\'>only the plain</strong> <em>text</em>. <img style=\'margin: 1px;\' src=\'images/smiley.png' alt=\'laughing' width=\'16' height=\'16'/></td><td> </td></tr><tr><td>Remove successive &nbsp;s</td><td>Never use non-breaking spaces to set margins.</td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Remove empty tags</td><td>Empty tags should go!</td><td> </td></tr><tr><td>Remove tags with one &nbsp;</td><td>This makes no sense!</td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Remove span tags</td><td>Span tags with <span style=\'color: green; font-size: 13px;\'>all styles</span></td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Remove images</td><td>I am an image: <img src=\'images/smiley.png' alt=\'laughing'/></td><td> </td></tr><tr><td>Remove links</td><td><a href=\'https://html-online.com' rel=\'nofollow\'>This is</a> a link.</td><td> </td></tr><tr><td>Remove tables</td><td>Takes everything out of the table.</td><td> </td></tr><tr><td>Replace table tags with structured divs</td><td>This text is inside a table.</td><td> </td></tr><tr><td>Remove comments</td><td>This is only visible in the source editor </td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Encode special characters</td><td><span style=\'color: red; font-size: 17px;\'>♥</span> <strong style=\'font-size: 20px;\'>☺ ★</strong> ><</td><td><strong style=\'font-size: 17px; color: #2b2301;\'>x</strong></td></tr><tr><td>Set new lines and text indents</td><td>Organize the tags in a nice tree view.</td><td> </td></tr></tbody></table><p><strong> </strong></p><p><strong>Save this link into your bookmarks and share it with your friends. It is all FREE! </strong><br/><strong>Enjoy!</strong></p><p><strong> </strong></p>";
var result1 = Markdig.Markdown.ToHtml(sampleMD3);
Console.WriteLine(result1);
Console.WriteLine("/////////////////////////////////////////////");
var result3 = CommonMark.CommonMarkConverter.Convert(sampleMD3);
Console.WriteLine(result3);
Console.WriteLine("/////////////////////////////////////////////");
var marked = new Marked();
var result4 = marked.Parse(sampleMD3);
Console.WriteLine(result4);
Console.WriteLine("/////////////////////////////////////////////");
var ct = new ReverseMarkdown.Converter();
string result2 = ct.Convert(sampleHTML);
Console.WriteLine(result2);
var crt = new Html2Markdown.Converter();
var markdown = crt.Convert(sampleHTML);
Console.WriteLine(markdown);
var endodedStr = System.Web.HttpUtility.UrlEncode(@"https://www.dabadabadu.co/fi?message=MN SMS Message: 189F#jG0xo!*9QOl&");
Console.WriteLine(endodedStr);
Console.WriteLine(GenerateSlug("Weekly (Tuesday + Thursday) with CI0000002"));
string last = "https://aldinfree.atlassian.net/rest/webhooks/1.0/webhook/52".Split('/').Last();
public static string GenerateSlug(string phrase)
string str = RemoveDiacritics(phrase).ToLower();
str = Regex.Replace(str, @"[^a-z0-9\s-]", "");
str = Regex.Replace(str, @"\s+", " ").Trim();
str = str.Substring(0, str.Length <= 45 ? str.Length : 45).Trim();
str = Regex.Replace(str, @"\s", "-");
public static string RemoveDiacritics(string text)
var normalizedString = text.Normalize(NormalizationForm.FormD);
var stringBuilder = new StringBuilder();
foreach (var c in normalizedString)
var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);