MarkdownSharp & GitHub syntax for C# code

前端 未结 3 1295
离开以前
离开以前 2020-12-28 14:20

Is there a way to get MarkdownSharp (I\'m using the NuGet package) to handle \'GitHub flavored Markdown (GFM)\' and especially syntax highlighting of c# code, which (in GFM)

3条回答
  •  醉梦人生
    2020-12-28 15:16

    As one can read in this post, GitHub relies on RedCarpet to render Markdown syntax.

    However, Vicent Marti (Sundown (ex-Upskirt) and RedCarpet maintainer) states that the syntax highlighting is specifically handled by Pygments, a python library.

    Back to your concern, I can think of several options to benefit from syntax highlighting from C#:

    • Try and build a compiled managed version of Pygments source code thanks to IronPython ("IronPython’s Hosting APIs can be used to compile Python scripts into DLLs, console executables, or Windows executables.")
    • Port Pygment to C#
    • Use a different syntax highlighting product (for instance, ColorCode which is used by Codeplex...)

    Then either:

    • Fork MarkDownSharp to make it accept plug-ins
    • Similarly to what GitHub does, use the managed syntax highlighting product and post process the Html generated by MarkDownSharp

    By the way, as a MarkDown alternative, you might want to consider Moonshine, a managed wrapper on top of Sundown which is said to be "at least 20x faster than MarkdownSharp when run against MarkdownSharp's own benchmark app."

提交回复
热议问题