using Markdig;
using Markdig.SyntaxHighlighting;

namespace MarkdownRenderer
{
    public static class MarkdownHtmlConverter
    {
        public static readonly MarkdownPipeline FullFunctionMarkdownPipeline;

        static MarkdownHtmlConverter()
        {
            //TODO: Check markdown extensions

            /*
             *  - [x] Lists:            Bulit-in is OK, Unordered/Ordered/Start numbering with offset
             *  - [x] Table:            +UsePipeTables+UseGridTables (require style sheet)
             *  - [x] Task:             +UseTaskLists
             *  - [X] Super/Subscript:  +UseEmphasisExtras
             *  - [X] Footnotes:        +UseFootnotes
             *  - [x] Syntax Coloring:  +UseSyntaxHighlighting (External extension)
             *  - [X] Emoji:            +UseEmojiAndSmiley (CEF:no work on HTML fragment,need complete page)
             *  - [x] Abbreviations:    +UseAbbreviations (CEF:tooltip not work?)
             *  - [ ] TOC:              ?? Like wikipedia
             *  - [ ] Typographer:      ?? (C) (R) (TM)
             */

            //Or try github.com/markdown-it/markdown-it

            FullFunctionMarkdownPipeline = new MarkdownPipelineBuilder()
                .UsePipeTables().UseGridTables()
                .UseTaskLists()
                .UseAbbreviations()
                .UseSyntaxHighlighting()
                .UseFootnotes()

                .UseEmojiAndSmiley()
                .UseEmphasisExtras()

                .UseSoftlineBreakAsHardlineBreak()
                .UseSmartyPants()

                //.UsePragmaLines()
                //.UseFooters()
                //.UseCustomContainers()
                //.UseDefinitionLists()

                .Build();
        }

        public static string ToHtml(string mdText)
        {
            return Markdown.ToHtml(mdText, FullFunctionMarkdownPipeline);
        }
    }
}