2

I have code written in any programming language. How can I "prettify" it (bold if, else etc.) to display on a website? Are there any good APIs to do that?

Thomas Eding
  • 35,312
  • 13
  • 75
  • 106
good_evening
  • 21,085
  • 65
  • 193
  • 298

4 Answers4

5

There is Google's prettify which is widely used for such tasks (e.g. SO itself uses it for highlighting of code).

Google Code Prettify JavaScript library supports all C-like (Java, PHP, C#, etc), Bash-like, and XML-like languages without need to specify the language and has customizable styles via CSS.

Moreover, as i know, there is a lot of third-party styles for those languages that not supported officially.

Community
  • 1
  • 1
om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
0

If you're using PHP, I recommend GeSHi

Michael Robinson
  • 29,278
  • 12
  • 104
  • 130
0

If you're talking about an auto-formatter, I've used PEAR's PHP Beautifer before.

Although you shouldn't really need a script to format your code for you...

hohner
  • 11,498
  • 8
  • 49
  • 84
0

This is the most common plugin used on the web I think.

I think it works for most programming languages.

I see it everywhere. I am actually thinking of adding it to my website as well.

Felipe
  • 11,557
  • 7
  • 56
  • 103