1<?php 2 3namespace dokuwiki\Parsing\ParserMode; 4 5use dokuwiki\Parsing\Handler; 6use dokuwiki\Parsing\ModeRegistry; 7 8class Eol extends AbstractMode 9{ 10 /** @inheritdoc */ 11 public function getSort() 12 { 13 return 370; 14 } 15 16 /** @inheritdoc */ 17 public function connectTo($mode) 18 { 19 if (in_array($mode, ModeRegistry::getInstance()->getBlockEolModes())) { 20 return; 21 } 22 // see FS#1652, pattern extended to swallow preceding whitespace to avoid 23 // issues with lines that only contain whitespace 24 $this->Lexer->addSpecialPattern('(?:^[ \t]*)?\n', $mode, 'eol'); 25 } 26 27 /** @inheritdoc */ 28 public function handle($match, $state, $pos, Handler $handler) 29 { 30 $handler->addCall('eol', [], $pos); 31 return true; 32 } 33} 34