nerocui / JitHubFeedback

Welcome to feedback for JitHub.
5 stars 0 forks source link

Use GitHub Markdown APIs #24

Closed 0x5bfa closed 2 years ago

0x5bfa commented 2 years ago

You can get closer to the GitHub UI by using the GitHub markdown rendering API and styles.

html: https://github.com/fluenthub-uwp/FluentHub/blob/main/FluentHub/Services/OctokitEx/Markdown.cs#L21

Rendered raw html: https://github.com/fluenthub-uwp/FluentHub/blob/main/FluentHub/Services/OctokitEx/Markdown.cs#L69

Fix relative path in html: https://github.com/fluenthub-uwp/FluentHub/blob/main/FluentHub/Services/OctokitEx/Markdown.cs#L43

string url = "https://api.github.com/markdown/raw";

try
{
    WebClient wc = new WebClient();

    wc.Headers["Content-Type"] = "text/plain";
    wc.Headers["User-agent"] = "FluentHub";

    var resData = wc.UploadData(url, "POST", Encoding.UTF8.GetBytes(markdown));
    wc.Dispose();

    string data = Encoding.UTF8.GetString(resData);

    return data;
}
catch (Exception e)
{
    Log.Error(e.ToString());
    return null;
}

And github markdown styles:

https://github.com/sindresorhus/github-markdown-css