Md2Word.cs
//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;
using DsWordWeb.Demos.MarkdownToWordRenderer;

namespace DsWordWeb.Demos
{
    // This example shows how to convert markdown (.md) documents
    // to MS Word DOCX and PDF formats.
    //
    // The conversion is done by the DsWordWeb.Demos.MarkdownToWordRenderer.WordRenderer
    // class that uses the Markdig package written by Alexandre Mutel
    //to parse markdown, and the DsWord OM to create MS Word documents from it.
    //
    // The WordRenderer C# source code is included in this sample, to view it
    // download the sample zip. The MarkdownToWordRenderer sources are located
    // in the Samples/Markdown/Renderer subdirectory of the sample zip.
    public class Md2Word
    {
        public GcWordDocument CreateDocx(string[] sampleParams)
        {
            var fn = Path.Combine(sampleParams[3].Split('/'));
            var markdown = File.ReadAllText(fn);
            return WordRenderer.ToWord(markdown);
        }

        public GcWordDocument CreateDocx(int parsIdx = 0)
        {
            return CreateDocx(GetSampleParamsList()[parsIdx]);
        }

        // Mandatory: name, description, info.
        // Custom: .md file.
        static readonly List<string[]> s_paramsList = new List<string[]>()
            {
                new string[] { "@md/DsPdfViewer README.md", "Convert the README.md file shipped with DsPdfViewer", null,
                    "Resources/Markdown/DsPdfViewer-README.md" },
                new string[] { "@md/DsPdfViewer CHANGELOG.md", "Convert the CHANGELOG.md file shipped with DsPdfViewer", null,
                    "Resources/Markdown/DsPdfViewer-CHANGELOG.md" },
                new string[] { "@md/spec.md", "Convert the Markdown specification spec.md file", null,
                    "Resources/Markdown/spec.md" },
            };

        public static List<string[]> GetSampleParamsList() => s_paramsList;
    }
}