Contents

Parsedown::inlineEmailTag( $Excerpt )

Description

Source

File: bp-help/vendors/parsedown/Parsedown.php

1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
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 array(
            'extent' => strlen($matches[0]),
            'element' => array(
                'name' => 'a',
                'text' => $matches[1],
                'attributes' => array(
                    'href' => $url,
                ),
            ),
        );
    }
}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.