Google Code Prettifierについて
Google Code Prettifierとは、google-code-prettifyはApache License Version 2.0のもとで公開されているHTMLなどで表示するソースコードやテキストをハイライト表示(強調表示)するJavaScriptモジュールです。Google Code Prettifierは、Googleでホスティングされています。
C、 C系、 Java、 Python、 Bash、 SQL、 HTML、 XML、 CSS、 Javascript、 Makefiles、 Rust、 Ruby、 PHP、 VB、 Awk、 Perl、 Rubyに対応しています。
google-code-prettify : http://code.google.com/p/google-code-prettify/
Google Code Prettifierの使用方法
1.スタイルシート(css)とJavaScriptファイル(js)をGoogle Code Prettifierのページからダウンロードします。
2.ハイライト表示(強調表示)するページに以下のスクリプトとCSSリンクタグを追加します。
<LINK rel="stylesheet" href="../google-code-prettify/prettify.css" type="text/css" /> <SCRIPT type="text/javascript" src="../google-code-prettify/prettify.js"></script>3.BODYタグに「onload="prettyPrint()"」のロードイベント処理を追加します。
4.ハイライトしたいソースを以下のようタグで囲みます。「language-html」は、ソースの言語に合わせて変更します。
5.「<」と「>」は、HTMLタグとして表示されるので、「<」「>」に変換します。
<PRE class="prettyprint linenums language-html"> </PRE>