1be906b56SAndreas Gohr<?php 2be906b56SAndreas Gohr 3be906b56SAndreas Gohrnamespace dokuwiki\Parsing\ParserMode; 4be906b56SAndreas Gohr 5*73dc0a89SAndreas Gohruse dokuwiki\MailUtils; 671096e46SAndreas Gohruse dokuwiki\Parsing\Handler; 771096e46SAndreas Gohr 8be906b56SAndreas Gohrclass Emaillink extends AbstractMode 9be906b56SAndreas Gohr{ 10be906b56SAndreas Gohr /** @inheritdoc */ 1171096e46SAndreas Gohr public function getSort() 1271096e46SAndreas Gohr { 1371096e46SAndreas Gohr return 340; 1471096e46SAndreas Gohr } 1571096e46SAndreas Gohr 1671096e46SAndreas Gohr /** @inheritdoc */ 17be906b56SAndreas Gohr public function connectTo($mode) 18be906b56SAndreas Gohr { 19*73dc0a89SAndreas Gohr $this->Lexer->addSpecialPattern('<' . MailUtils::PREG_PATTERN_VALID_EMAIL . '>', $mode, 'emaillink'); 20be906b56SAndreas Gohr } 21be906b56SAndreas Gohr 22be906b56SAndreas Gohr /** @inheritdoc */ 2371096e46SAndreas Gohr public function handle($match, $state, $pos, Handler $handler) 24be906b56SAndreas Gohr { 2571096e46SAndreas Gohr $email = preg_replace(['/^</', '/>$/'], '', $match); 2671096e46SAndreas Gohr $handler->addCall('emaillink', [$email, null], $pos); 2771096e46SAndreas Gohr return true; 28be906b56SAndreas Gohr } 29be906b56SAndreas Gohr} 30