コードをハイライト表示するjavascript「Chili」
HTMLやJavascript、PHPなどのソースを紹介する時にはわかりやすい表示が求められます。
Chili Centralでは、コードをハイライト表示するChiliを公開しています。
使用方法
Chili Centralからchiliのファイル群をダウンロードし、全てアップロードします。
<script type="text/javascript" src="http://yourdomain/jquery.js"></script>
<script type="text/javascript" src="http://yourdomain/chili.pack.js"></script>
<script type="text/javascript">
ChiliBook.recipeFolder = "http://yourdomain/chili/";
ChiliBook.stylesheetFolder = "http://yourdomain/chili/";
</script>
上記の様に書き込んだら、codeを記述する時にclassにhtmlやjavascriptなど対応する言語名を付与すれば完成です。
<code class="html">
<!-- ここにソースを書き込む -->
</code>
Javascriptサンプルページ一覧
skuare.net
サンプル
mySQL
/*
extracted from "Advanced MySQL user variable techniques"
(http://www.xaprb.com/blog/2006/12/15/advanced-mysql-user-variable-techniques/)
*/
CREATE TABLE fruits (
`type` varchar(10) NOT NULL,
variety varchar(20) NOT NULL,
price decimal(5,2) NOT NULL default 0,
PRIMARY KEY (`type`,variety)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into fruits(`type`, variety, price) values
('apple', 'gala', 2.79),
('apple', 'fuji', 0.24),
('apple', 'limbertwig', 2.87),
('orange', 'valencia', 3.59),
('orange', 'navel', 9.36),
('pear', 'bradford', 6.05),
('pear', 'bartlett', 2.14),
('cherry', 'bing', 2.55),
('cherry', 'chelan', 6.33);
set @num := 0, @type := '';
select `type`, variety, price, @num
from fruits
where 2 >= greatest(
@num := if(@type = `type`, @num + 1, 1),
least(0, length(@type := `type`)));