问题描述
我需要创建一个可以将 Markdown 文件转换为 HTML 文件和 DTX 文件的控制台应用程序。
但我什至不知道如何开始转换为DTX。
转换为 HTML 使用 Markdig 工作。我就是这样做的:
static void Convert2HTML(string file)
{
string sourceFile = Path.GetFullPath(file);
string sourceText = File.ReadAllText(sourceFile);
string reswText = Markdown.ToHtml(sourceText);
string destinationPath = Path.GetDirectoryName(sourceFile);
string newFile = Path.ChangeExtension(file,".html");
string savePath = Path.Combine(destinationPath,newFile);
if (!File.Exists(newFile))
{
//creates a a html file
File.Create(newFile).Close();
File.WriteAllText(savePath,reswText);
}
else
{
//overwrites file
File.WriteAllText(savePath,sourceText);
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)