protected function handleTag_a_converter($tag, $buffer)
{
if (empty($tag['href']) && empty($tag['title'])) {
// empty links... testcase mania, who would possibly do anything like that?!
return '[' . $buffer . ']()';
}
if ($buffer == $tag['href'] && empty($tag['title'])) {
// <http://example.com>
return '<' . $buffer . '>';
}
$bufferDecoded = $this->decode(trim($buffer));
if (substr($tag['href'], 0, 7) == 'mailto:' && 'mailto:' . $bufferDecoded == $tag['href']) {
if (is_null($tag['title'])) {
// <[email protected]>
return '<' . $bufferDecoded . '>';
}
// [[email protected]][1]
// ...
// [1]: mailto:[email protected] Title
$tag['href'] = 'mailto:' . $bufferDecoded;
}
if ($this->linkPosition == self::LINK_IN_PARAGRAPH) {
return '[' . $buffer . '](' . $this->getLinkReference($tag) . ')';
}
// [This link][id]
foreach ($this->footnotes as $tag2) {
if ($tag2['href'] == $tag['href'] && $tag2['title'] === $tag['title']) {
$tag['linkID'] = $tag2['linkID'];
break;
}
}
if (!isset($tag['linkID'])) {
$tag['linkID'] = count($this->footnotes) + 1;
array_push($this->footnotes, $tag);
}
return '[' . $buffer . '][' . $tag['linkID'] . ']';
}