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 connectTo($mode) 24 { 25 $this->Lexer->addEntryPattern('[\t ]*\n\^', $mode, 'table'); 26 $this->Lexer->addEntryPattern('[\t ]*\n\|', $mode, 'table'); 27 } 28 29 /** @inheritdoc */ 30 public function postConnect() 31 { 32 $this->Lexer->addPattern('\n\^', 'table'); 33 $this->Lexer->addPattern('\n\|', 'table'); 34 $this->Lexer->addPattern('[\t ]*:::[\t ]*(?=[\|\^])', 'table'); 35 $this->Lexer->addPattern('[\t ]+', 'table'); 36 $this->Lexer->addPattern('\^', 'table'); 37 $this->Lexer->addPattern('\|', 'table'); 38 $this->Lexer->addExitPattern('\n', 'table'); 39 } 40 41 /** @inheritdoc */ 42 public function getSort() 43 { 44 return 60; 45 } 46} 47