1<?php 2 3namespace dokuwiki\Parsing\ParserMode; 4 5use dokuwiki\Parsing\ModeRegistry; 6 7class Table extends AbstractMode 8{ 9 /** 10 * Table constructor. 11 */ 12 public function __construct() 13 { 14 $this->allowedModes = ModeRegistry::getInstance()->getModesForCategories([ 15 ModeRegistry::CATEGORY_FORMATTING, 16 ModeRegistry::CATEGORY_SUBSTITION, 17 ModeRegistry::CATEGORY_DISABLED, 18 ModeRegistry::CATEGORY_PROTECTED, 19 ]); 20 } 21 22 /** @inheritdoc */ 23 public function preConnect() 24 { 25 ModeRegistry::getInstance()->registerBlockEolMode('table'); 26 } 27 28 /** @inheritdoc */ 29 public function connectTo($mode) 30 { 31 $this->Lexer->addEntryPattern('[\t ]*\n\^', $mode, 'table'); 32 $this->Lexer->addEntryPattern('[\t ]*\n\|', $mode, 'table'); 33 } 34 35 /** @inheritdoc */ 36 public function postConnect() 37 { 38 $this->Lexer->addPattern('\n\^', 'table'); 39 $this->Lexer->addPattern('\n\|', 'table'); 40 $this->Lexer->addPattern('[\t ]*:::[\t ]*(?=[\|\^])', 'table'); 41 $this->Lexer->addPattern('[\t ]+', 'table'); 42 $this->Lexer->addPattern('\^', 'table'); 43 $this->Lexer->addPattern('\|', 'table'); 44 $this->Lexer->addExitPattern('\n', 'table'); 45 } 46 47 /** @inheritdoc */ 48 public function getSort() 49 { 50 return 60; 51 } 52} 53