将Html或RTF转换为Markdown或Wiki兼容语法?

是否有.net api可以做到这一点? 我看到Pandoc有一个独立的exe,我可以包装,但我不想,如果有东西已经存在。 有什么建议?

这是我用来包装pandoc的代码。 到目前为止,我还没有看到任何其他不错的方法。

public string Convert(string source) { string processName = @"C:\Program Files\Pandoc\bin\pandoc.exe"; string args = String.Format(@"-r html -t mediawiki"); ProcessStartInfo psi = new ProcessStartInfo(processName, args); psi.RedirectStandardOutput = true; psi.RedirectStandardInput = true; Process p = new Process(); p.StartInfo = psi; psi.UseShellExecute = false; p.Start(); string outputString = ""; byte[] inputBuffer = Encoding.UTF8.GetBytes(source); p.StandardInput.BaseStream.Write(inputBuffer, 0, inputBuffer.Length); p.StandardInput.Close(); p.WaitForExit(2000); using (System.IO.StreamReader sr = new System.IO.StreamReader( p.StandardOutput.BaseStream)) { outputString = sr.ReadToEnd(); } return outputString; } 

我创建了一个库Html2Markdown 。 用法很简单。

 var markdown = new Converter().Convert(html); 

其中html是您要转换的HTML的字符串表示forms。 我积极支持它并愉快地接受贡献。