Search code examples
javajavascripthtmlxmlpretty-print

Pretty-print Java, XML, JavaScript, ... to HTML


I have a step-by-step tutorial of how to setup our product. I have to display lots of sample code in each step. Following is the list of types of code I have to display in the page. What do I use to format everything?

  • Java Code Samples
  • XML samples
  • iOS SDK Files (*.h and *.m)
  • Javascript code samples

My product UI is JavaScript based. We are using knockout bindings and MVVM.

Edit: This is for our web based product. We display some code samples on our tutorials page so that the user can copy paste the sample code into their IDEs. Code should be displayed on an HTML page.


Solution

  • Checkout google-code-prettify, which is used here on Stack Overflow and code.google.com. It works with Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, Makefiles, and Rust. You can see samples in its Gallery of themes.