-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
46 lines (41 loc) · 1.5 KB
/
Program.cs
File metadata and controls
46 lines (41 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.IO;
using Markdig;
using Markdig.SyntaxHighlighting;
namespace md2html
{
internal class Program
{
static void Main(string[] argv)
{
if (argv.Length != 2)
{
Usage();
Environment.Exit(1);
}
string mdFname = argv[0];
string htmlFname = argv[1];
#if DEBUG
Console.WriteLine($"argv count: {argv.Length}");
Console.WriteLine("md file: " + mdFname);
Console.WriteLine("html file: " + htmlFname);
Console.WriteLine($"cwd: {Environment.CurrentDirectory}{Path.DirectorySeparatorChar}");
#endif
string md = File.ReadAllText(mdFname);
var pipeline = new Markdig.MarkdownPipelineBuilder()
.UseAdvancedExtensions()
.UseYamlFrontMatter()
.UseSyntaxHighlighting(null).Build();
// Console.WriteLine(Markdown.ToHtml(md, pipeline));
File.WriteAllText($"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}{htmlFname}",
Markdown.ToHtml(md, pipeline));
// File.WriteAllText($"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}",
// Markdown.ToHtml(md, pipeline));
}
static void Usage()
{
Console.WriteLine("Usage:");
Console.WriteLine(" md2html [markdown file] [html file]");
}
}
}