I am writing a command line tool to convert Markdown text to html output, which seems easy enough.
However, I am wondering how to get nice syntax coloring for embedded code blocks, like the one used by Stack Overflow.
Does anyone know either:
What library StackOverflow is using
or if there's a library out there that I can easily reuse?
Basically it would need to have some of the same "intelligence" found in the one that Stack Overflow uses, by basically doing a best-attempt at figuring out the language in use to pick the right keywords.
Basically, what I want is for my own program to handle a block like the following:
if (a == 0) return true;
if (a == 1) return false; // fall-back
Markdown Sharp, the library I'm using, by default outputs the above as a simple pre/code html block, with no syntax coloring.
I'd like the same type of handling as the formatting on Stack Overflow does, the above contains blue "return" keywords for example.
Or, hmm, after checking the source of this Stack Overflow page after adding the code example, I notice that it too is formatted like a simple pre/code block. Is it pure javascript-magic at works here, so perhaps there's no such library?
If there's no library that will automagically determine a possible language by the keywords used, is there one that would work if I explicitly told it the language? Since this is "my" markdown-commandline-tool, I can easily add syntax if I need to.