function Markdown_Parser::doAnchors in Markdown 5
Same name and namespace in other branches
- 6 markdown.php \Markdown_Parser::doAnchors()
File
- ./markdown.php, line 652
Class
- Markdown_Parser
Code
function doAnchors($text) {
if ($this->in_anchor) {
return $text;
}
$this->in_anchor = true;
$text = preg_replace_callback('{
( # wrap whole match in $1
\\[
(' . $this->nested_brackets_re . ') # link text = $2
\\]
[ ]? # one optional space
(?:\\n[ ]*)? # one optional newline followed by spaces
\\[
(.*?) # id = $3
\\]
)
}xs', array(
&$this,
'_doAnchors_reference_callback',
), $text);
$text = preg_replace_callback('{
( # wrap whole match in $1
\\[
(' . $this->nested_brackets_re . ') # link text = $2
\\]
\\( # literal paren
[ ]*
(?:
<(\\S*)> # href = $3
|
(' . $this->nested_url_parenthesis_re . ') # href = $4
)
[ ]*
( # $5
([\'"]) # quote char = $6
(.*?) # Title = $7
\\6 # matching quote
[ ]* # ignore any spaces/tabs between closing quote and )
)? # title is optional
\\)
)
}xs', array(
&$this,
'_DoAnchors_inline_callback',
), $text);
$this->in_anchor = false;
return $text;
}