This question appears to be off-topic. The users who voted to close gave this specific reason:

"Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – FallenAngel, Blackhole, Clockwork-Muse, Matthieu M., OneOfOne

may i mention this site is terrible at doing this? (at least in my opinion)
–
ClaudiuNov 28 '08 at 8:06

A little is better than nothing. MarkDown is OSS, so he can fix anything he needs.
–
Aaron DigullaNov 28 '08 at 8:22

1

Markdown does no syntax colouring at all, it just turns blah into <b></b> tags and other such formatting. The syntax highlighting is done by google-code-pretty (in javascript). I added it to your answer, hope you don't mind..
–
dbrNov 28 '08 at 8:28

So "all" he has to do is convert the Javascript (the library) to Python (what he uses)...
–
bartNov 28 '08 at 9:29

What better solution is there when there is no existing Python library?
–
Aaron DigullaNov 28 '08 at 9:55

This can be a little difficult to do reliably. For example, what language is the following:

print("blah");

The most reliable way (aside from having the user select the correct language, of course) is to check if the first line is starts with #! ("hashbang") - whatever is after this is the intepreter for the scripting language.

That will work reliably for a lot of scripting languages (including python, shell scripting, perl, ruby etc etc..), but not for compiled languages..

You could look for unique syntax stylings, or specific keywords and weight each one towards a specific language. For example $#somevar is probably Perl. somevar.each do |another| ..... end is probably ruby.. but this would end up being a lot of work, and will not always work (especially with short code blocks)

The other obvious way is to use the file-extension. If it's *.pl it's probably Perl code..

What are you trying to achieve? If you want to syntax highlight, look at what google-code-prettify does - basically a reasonably intelligent, generic syntax highlighter..

In the above above ambiguous example, print is probably a statement or function name, "blah" is probably a string. If you highlight those two differently, you've successfully highlighted a lot of different languages, without having to detect what one it actually is.. but that may not always work, depending on the task..