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