C # /. NET for formatting source code like used by stack overflow?

I am writing a command line tool to convert Markdown text to html output, which seems simple enough.

However, I am wondering how to get beautiful syntax coloring for inline blocks of code, such as the one used by Stack Overflow.

Somebody knows:

  • Which StackOverflow library is used
  • or if there is a library that I can easily reuse?

In principle, in order to find suitable keywords, you will need to find the same “intelligence” in what Stack Overflow uses, basically making the best attempt to figure out the language used.

Basically, I want my own program to process the block as follows:

if (a == 0) return true;
if (a == 1) return false; // fall-back

Markdown Sharp, the library I use, by default displays the above as a simple pre / code html block without syntax coloring.

I need the same type of processing as formatting in Stack Overflow, the above contains the blue words "return", for example.

Or, hmm, after checking the source of this page after adding the sample code, I noticed that it is also formatted as a simple pre / code block. This is pure javascript magic when working here, so maybe there is no such library?

If there is no library that automatically determines the possible language by the keywords used, is there one that would work if I directly told him the language? Since this is my markdown command line tool, I can easily add syntax if I need to.

+3
1

- , Markdown Sharp - Markdown, .

Google Code Prettify - , . , ?

+7

Source: https://habr.com/ru/post/1729796/


All Articles