<commit_before>﻿// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DocAsCode.Dfm.VscPreview
{
    using System;
    using System.IO;
    using System.Text;

    using Microsoft.DocAsCode.Dfm;
    using Microsoft.DocAsCode.Build.Engine;
    using Microsoft.DocAsCode.MarkdownLite;
    using Microsoft.DocAsCode.Plugins;

    internal class Program
    {
        static void Main(string[] args)
        {
            try
            {
                while (true)
                {
                    // path -> basedir
                    string path = Console.ReadLine();
                    if (path == "exit")
                        break;
                    // filename -> the relative path of the current file
                    string filename = Console.ReadLine();

                    // a simple protocol(get String According to the numOfRow and connect them)
                    string numStr = Console.ReadLine();
                    int numOfRow = Convert.ToInt32(numStr);
                    StringBuilder markdownContent = new StringBuilder();
                    for (int i = 0; i < numOfRow; i++)
                    {
                        markdownContent.AppendLine(Console.ReadLine());
                    }
                    DfmServiceProvider dfmServiceProvider = new DfmServiceProvider();
                    MarkdownServiceParameters markdownServiceParameters = new MarkdownServiceParameters();
                    markdownServiceParameters.BasePath = path;
                    IMarkdownService iMarkdownService = dfmServiceProvider.CreateMarkdownService(markdownServiceParameters);
                    var result = iMarkdownService.Markup(markdownContent.ToString(), filename).Html;

                    // append with customized endCode
                    Console.Write(result);
                    Console.Write('\a');
                }
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine($"error:{e.Message}");
                return;
            }
        }
    }
}
<commit_msg>extract the call of dfmservice to a method<commit_after>﻿// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DocAsCode.Dfm.VscPreview
{
    using System;
    using System.IO;
    using System.Text;

    using Microsoft.DocAsCode.Dfm;
    using Microsoft.DocAsCode.Build.Engine;
    using Microsoft.DocAsCode.MarkdownLite;
    using Microsoft.DocAsCode.Plugins;

    internal class Program
    {
        static void Main(string[] args)
        {
            try
            {
                while (true)
                {
                    // path -> basedir
                    string path = Console.ReadLine();
                    if (path == "exit")
                        break;
                    // filename -> the relative path of the current file
                    string filename = Console.ReadLine();

                    // a simple protocol(get String According to the numOfRow and connect them)
                    string numStr = Console.ReadLine();
                    int numOfRow = Convert.ToInt32(numStr);
                    StringBuilder markdownContent = new StringBuilder();
                    for (int i = 0; i < numOfRow; i++)
                    {
                        markdownContent.AppendLine(Console.ReadLine());
                    }
                    var result = Dfmprocess(path, filename, markdownContent.ToString());

                    // append with customized endCode
                    Console.Write(result);
                    Console.Write('\a');
                }
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine($"error:{e.Message}");
                return;
            }
        }

        public static string Dfmprocess(string path, string filename, string markdownContent)
        {
            DfmServiceProvider dfmServiceProvider = new DfmServiceProvider();
            MarkdownServiceParameters markdownServiceParameters = new MarkdownServiceParameters();
            markdownServiceParameters.BasePath = path;
            IMarkdownService dfmService = dfmServiceProvider.CreateMarkdownService(markdownServiceParameters);
            return dfmService.Markup(markdownContent, filename).Html;
        }
    }
}

{'fraction_non_alphanumeric': 0.07555847568988174, 'fraction_numerical': 0.001314060446780552, 'mean_word_length': 1.5148678414096917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1558112', 'n_tokens_mistral': 1068, 'n_tokens_neox': 998, 'n_words': 274}