本文整理汇总了PHP中Markdown::in_anchor方法的典型用法代码示例。如果您正苦于以下问题:PHP Markdown::in_anchor方法的具体用法?PHP Markdown::in_anchor怎么用?PHP Markdown::in_anchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Markdown
的用法示例。
在下文中一共展示了Markdown::in_anchor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_anchors
/**
* Turn Markdown link shortcuts into XHTML <a> tags.
*/
private static function do_anchors($text)
{
if (self::$in_anchor) {
return $text;
}
self::$in_anchor = TRUE;
// First, handle reference-style links: [link text] [id]
$text = preg_replace_callback('{
( # wrap whole match in $1
\\[
(' . self::$nested_brackets_re . ') # link text = $2
\\]
[ ]? # one optional space
(?:\\n[ ]*)? # one optional newline followed by spaces
\\[
(.*?) # id = $3
\\]
)
}xs', array(__CLASS__, '_do_anchors_reference_callback'), $text);
// Next, inline-style links: [link text](url "optional title")
$text = preg_replace_callback('{
( # wrap whole match in $1
\\[
(' . self::$nested_brackets_re . ') # link text = $2
\\]
\\( # literal paren
[ \\n]*
(?:
<(.+?)> # href = $3
|
(' . self::$nested_url_parenthesis_re . ') # href = $4
)
[ \\n]*
( # $5
([\'"]) # quote char = $6
(.*?) # Title = $7
\\6 # matching quote
[ \\n]* # ignore any spaces/tabs between closing quote and )
)? # title is optional
\\)
)
}xs', array(__CLASS__, '_do_anchors_inline_callback'), $text);
/*
* Last, handle reference-style shortcuts: [link text]
* These must come last in case you've also got [link text][1]
* or [link text](/foo)
*/
$text = preg_replace_callback('{
( # wrap whole match in $1
\\[
([^\\[\\]]+) # link text = $2; cant contain [ or ]
\\]
)
}xs', array(__CLASS__, '_do_anchors_reference_callback'), $text);
self::$in_anchor = FALSE;
return $text;
}