Google Code Prettify 的使用方式就是這麼簡單,會自動判斷要上色的關鍵字,支援多種語言如 C 語言家族、Java、Python、Bash、SQL、HTML、XML、CSS、Javascript、Makefiles 等,對於 Perl、Ruby、PHP、VB、Awk 也部份支援。底下是一些其他範例:
這是 Google Maps API 的第一個範例:
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg&sensor=true_or_false"
type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>
</body>
</html>
C++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Java
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello, world!n");
}
}