プログラムを生成します。
<?
/**
* lisp 文字列を適当に色分けする( 本当は色分けではなくスタイル設定)
* @since 03/04/28 11:45
* @param String $file 色分けする文字列
* @return String 色分けされた文字列
*/
function lisp_coloring( $file ){
$file = htmlspecialchars( $file );
$file = str_replace( "\t"," ",$file );
$file = preg_replace( '/\"\;(((?!"\;).)|\\\\\"\;)*?\"\;/','<span class=lispstring>$0</span>',$file );
$file = preg_replace( '/\B;(.*)/','<span class=lispcomment>$0</span>',$file );
while( preg_match( '{(\/span\>[^\<]*\s)([0-9]+|nil|t)}', $file, $reg ) ) $file = str_replace( $reg[0], "$reg[1]<span class=lispnum>$reg[2]</span>", $file );
while( preg_match( '{(\/span\>[^\<]*\s)(\:[-a-zA-Z0-9]+)}', $file, $reg ) ) $file = str_replace( $reg[0], "$reg[1]<span class=lispopt>$reg[2]</span>", $file );
while( preg_match( '{(\/span\>[^\<]*)([()])}', $file, $reg ) ) $file = str_replace( $reg[0], "$reg[1]<span class=lispparentheses>$reg[2]</span>", $file );
return $file;
}
/**
* lisp ファイルを適当に色分けする( 本当は色分けではなくスタイル設定)
* @since 03/04/28 11:46
* @param String $filename ファイル名
*/
function output_lisp($filename){
print( "<pre class=xyzzycode>" . lisp_coloring( mb_convert_encoding(join("", file($filename)),"euc","sjis") ) . "</pre>" );
}
?>