本文整理匯總了PHP中ParsedownExtra::identifyLink方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParsedownExtra::identifyLink方法的具體用法?PHP ParsedownExtra::identifyLink怎麽用?PHP ParsedownExtra::identifyLink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ParsedownExtra
的用法示例。
在下文中一共展示了ParsedownExtra::identifyLink方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: identifyLink
protected function identifyLink($Excerpt)
{
$r = parent::identifyLink($Excerpt);
if (isset($r['element']['name']) && $r['element']['name'] == 'img') {
$r['element']['attributes']['src'] = '/doc/' . $r['element']['attributes']['src'];
}
return $r;
}
示例2: identifyLink
protected function identifyLink($Excerpt)
{
$result = parent::identifyLink($Excerpt);
$text = $result['element']['text'];
$href = $result['element']['attributes']['href'];
$mode_clear = false;
if ($text[0] === '!' && $text[1] === ':') {
$mode_clear = true;
$result['element']['text'] = $text = substr($text, 2);
}
// <a target="_self" class="tpl-inlink" href="#%s">%s<i class="fa fa-caret-square-o-up"></i></a>
if ($href[0] === '#') {
$result['element']['text'] .= '<i class="fa fa-caret-square-o-up"></i>';
$result['element']['attributes']['class'] = 'tpl-inlink';
} else {
// <a target="_blank" class="tpl-git" href="https://github.com/kakserpom/phpdaemon/tree/master/%s">%s<i class="fa fa-github"></i></a>
if (preg_match('/^[a-z]+\\:\\/\\/github\\.com\\//i', $href)) {
if ($result['element']['text'] === 'i') {
$result['element']['text'] = '<i class="fa fa-github"></i>';
$result['element']['attributes']['class'] = 'tpl-git';
} else {
$result['element']['text'] .= '<i class="fa fa-github"></i>';
$result['element']['attributes']['class'] = 'tpl-git tpl-git-text';
}
$result['element']['attributes']['target'] = '_blank';
} else {
if (preg_match('/^([a-z]+\\:\\/\\/)PHPDaemon\\//i', $href, $matches)) {
if ($result['element']['text'] === 'i') {
$result['element']['text'] = '<i class="fa fa-github"></i>';
$result['element']['attributes']['class'] = 'tpl-git';
} else {
$result['element']['text'] .= '<i class="fa fa-github"></i>';
$result['element']['attributes']['class'] = 'tpl-git tpl-git-text';
}
$result['element']['attributes']['href'] = 'https://github.com/kakserpom/phpdaemon/tree/master/' . substr($href, strlen($matches[1]));
$result['element']['attributes']['target'] = '_blank';
} else {
// <a target="_blank" class="tpl-outlink" href="%s">%s<i class="fa fa-external-link"></i></a>
if (preg_match('/^[a-z]+\\:\\/\\//i', $href)) {
$result['element']['text'] .= '<i class="fa fa-external-link"></i>';
$result['element']['attributes']['class'] = 'tpl-outlink';
$result['element']['attributes']['target'] = '_blank';
}
}
}
}
if ($mode_clear) {
$result['element']['text'] = $text;
if (isset($result['element']['attributes']['class'])) {
unset($result['element']['attributes']['class']);
}
}
return $result;
}