1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Implement Email

This commit is contained in:
Aidan Woods
2019-01-20 02:34:19 +00:00
parent 497045d25b
commit f2a3a2fb08
2 changed files with 67 additions and 29 deletions

View File

@ -411,35 +411,6 @@ class Parsedown
return $Elements;
}
protected function inlineEmailTag($Excerpt)
{
$hostnameLabel = '[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?';
$commonMarkEmail = '[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]++@'
. $hostnameLabel . '(?:\.' . $hostnameLabel . ')*';
if (\strpos($Excerpt['text'], '>') !== false
and \preg_match("/^<((mailto:)?$commonMarkEmail)>/i", $Excerpt['text'], $matches)
) {
$url = $matches[1];
if (! isset($matches[2])) {
$url = "mailto:$url";
}
return [
'extent' => \strlen($matches[0]),
'element' => [
'name' => 'a',
'text' => $matches[1],
'attributes' => [
'href' => $url,
],
],
];
}
}
protected function inlineEmphasis($Excerpt)
{
if (! isset($Excerpt['text'][1])) {