GeSHi をマークダウンで動作させようとしています。
Geshi の簡単な使い方は次のとおりです。
$geshi = new GeSHi($message, 'c');
print $geshi->parse_code();
上記のコードはメッセージ全体を取り込み、それを強調表示されたコードに変換します
Markdown関数もあります
print Markdown($message);
マークダウンから返されpreg_match
たタグにコールバック関数を使用し、返された値で関数を実行しようとしていました<pre>
geshi->parse_code();
これが私のコードです
print preg_replace_callback(
'/<pre.*?>(.*?[<pre.*?>.*<\/pre>]*)<\/pre>/gism',
create_function(
// single quotes are essential here,
// or alternative escape all $ as \$
'$matches',
'$geshi = new GeSHi($matches[0], \'php\'); return $geshi->parse_code()'
),
Markdown($blog_res['message']));
私は正しい軌道に乗っていますか?
私の正規表現は正しいですか?http://gskinner.com/RegExr/で動作します
助けてくれてありがとう