1<?php 2 3namespace dokuwiki\Parsing\ParserMode; 4 5use dokuwiki\MailUtils; 6use dokuwiki\Parsing\Handler; 7 8class Emaillink extends AbstractMode 9{ 10 /** @inheritdoc */ 11 public function getSort() 12 { 13 return 340; 14 } 15 16 /** @inheritdoc */ 17 public function connectTo($mode) 18 { 19 $this->Lexer->addSpecialPattern('<' . MailUtils::PREG_PATTERN_VALID_EMAIL . '>', $mode, 'emaillink'); 20 } 21 22 /** @inheritdoc */ 23 public function handle($match, $state, $pos, Handler $handler) 24 { 25 $email = preg_replace(['/^</', '/>$/'], '', $match); 26 $handler->addCall('emaillink', [$email, null], $pos); 27 return true; 28 } 29} 30