本文整理匯總了PHP中Michelf\MarkdownExtra::_doFencedCodeBlocks_callback方法的典型用法代碼示例。如果您正苦於以下問題:PHP MarkdownExtra::_doFencedCodeBlocks_callback方法的具體用法?PHP MarkdownExtra::_doFencedCodeBlocks_callback怎麽用?PHP MarkdownExtra::_doFencedCodeBlocks_callback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Michelf\MarkdownExtra
的用法示例。
在下文中一共展示了MarkdownExtra::_doFencedCodeBlocks_callback方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _doFencedCodeBlocks_callback
protected function _doFencedCodeBlocks_callback($matches)
{
$hashes =& $this->html_hashes;
$classname =& $matches[2];
$attrs =& $matches[3];
$codeblock = $matches[4];
$html = parent::_doFencedCodeBlocks_callback($matches);
preg_replace_callback('/B\\x1A[0-9]+B/', function ($blockHashMatches) use(&$hashes) {
$hashId = $blockHashMatches[0];
if (array_key_exists($hashId, $hashes)) {
$hashes[$hashId] = preg_replace_callback('|<pre class="shell">(.*?)</pre>|s', function ($codeBlockMatches) {
$shellCode = $codeBlockMatches[1];
$shellCode = preg_replace_callback('/^([^\\s]+\\s+)([^\\s]+\\s+)([#$])\\s+(.*)/m', function ($commandMatches) {
$shellUser = trim($commandMatches[1]);
$shellPromptPath = trim($commandMatches[2]);
$shellPromptSymbol = $commandMatches[3];
$shellCommand = trim($commandMatches[4]);
$html = '';
if ($shellUser) {
$html .= '<span class="shell-user">' . $shellUser . '</span> ';
}
if ($shellPromptPath || $shellPromptSymbol) {
$html .= '<span class="shell-prompt">' . trim($shellPromptPath . ' ' . $shellPromptSymbol) . '</span> ';
}
if (preg_match('/(.*?)\\[\\[\\[(.*?)\\]\\]\\](.*)/', $shellCommand, $selectionMatches)) {
$html .= $selectionMatches[1] . '<span class="shell-command">' . $selectionMatches[2] . '</span>' . $selectionMatches[3];
} else {
$html .= '<span class="shell-command">' . $shellCommand . '</span>';
}
return "<p>{$html}</p>";
}, $shellCode);
return '<pre class="shell">' . $shellCode . '</pre>';
}, $hashes[$hashId]);
}
return $hashId;
}, $html);
return $html;
}