Kreisquadratur» Blog Archive » Erlang syntax highlighting for GeSHi
こちらで配布されているErlangプラグインを利用するとセミコロンが <SEMI> に変換されてしまう、という問題について。先日は変数名のハイライトを諦めることでお茶を濁したが、やっぱりこれはGeSHiの仕様が悪いだろう、と思ったのでgeshi.phpを次のように修正した。
(’<SEMI>’ を “\x8″ に全置換しただけ。下のパッチはバージョン1.0.8の場合)
@@ -1942,7 +1942,7 @@ //This fix is related to SF#1923020, but has to be applied regardless of //actually highlighting symbols. - $result = str_replace(array('<SEMI>', '<PIPE>'), array(';', '|'), $result); + $result = str_replace(array("\x8", '<PIPE>'), array(';', '|'), $result); // Timing is irrelevant $this->set_time($start_time, $start_time); @@ -2774,7 +2774,7 @@ //This fix is related to SF#1923020, but has to be applied regardless of //actually highlighting symbols. /** NOTE: memorypeak #3 */ - $endresult = str_replace(array('<SEMI>', '<PIPE>'), array(';', '|'), $endresult); + $endresult = str_replace(array("\x8", '<PIPE>'), array(';', '|'), $endresult); // // Parse the last stuff (redundant?) // $result .= $this->parse_non_string_part($stuff_to_parse); @@ -3952,7 +3952,7 @@ //Circumvent a bug with symbol highlighting //This is required as ; would produce undesirable side-effects if it //was not to be processed as an entity. - ';' => '<SEMI>', // Force ; to be processed as entity + ';' => "\x8", // Force ; to be processed as entity '|' => '<PIPE>' // Force | to be processed as entity ); // ENT_COMPAT set
コードの中にバイナリの 0×08 = 制御文字のバックスペースが含まれることはまずないので、問題にはならないはず。少なくとも <SEMI>よりはマシなはず。
これでErlangモードがきちんと動くようになった。
fac(0) -> 1; fac(N) -> N * fac(N-1).