本文整理汇总了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;
}