开发者

Convert Html or RTF to Markdown or Wiki Compatible syntax? [closed]

Closed. This question is seeking recommendations for books, tools, software libraries, and more. It does not meet Stack Overflow guidelines guidel开发者_StackOverflow中文版ines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

Is there a .net api that can do this? I saw Pandoc has a standalone exe that I could wrap but I'd rather not if there is something already out there. Any suggestions?


Here's the code I used to wrap pandoc. I haven't seen any other decent methods so far unfortunately.

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;
}


I have created a library Html2Markdown. Usage is very simple.

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

Where html is the string representation of the HTML you wish to convert. I actively support it and happily accept contributions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜