Skip to content

Commit

Permalink
add class property pluginMode
Browse files Browse the repository at this point in the history
  • Loading branch information
ssahara committed Jan 21, 2016
1 parent 2e85e66 commit 5d510f6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions syntax.php
Expand Up @@ -13,11 +13,14 @@

class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {

protected $pluginMode;
protected $stack = array(); // stack of current open tag - used by handle() method
protected $tagsmap = array();
protected $attrsmap = array();

function __construct() {
$this->pluginMode = substr(get_class($this), 7);

// define name, prefix and postfix of tags
$this->tagsmap = array(
'table' => array("", "\n" ), // table start : {|
Expand Down Expand Up @@ -56,7 +59,7 @@ function getAllowedTypes() {
}
// override default accepts() method to allow nesting
public function accepts($mode) {
if ($mode == substr(get_class($this), 7)) return true;
if ($mode == $this->pluginMode) return true;
return parent::accepts($mode);
}

Expand All @@ -65,26 +68,24 @@ public function accepts($mode) {
* modified from original exttab2 code
*/
function connectTo($mode) {
$pluginMode = 'plugin_'.$this->getPluginName();
// table start: {| attrs
$this->Lexer->addEntryPattern('\n\{\|[^\n]*',$mode, $pluginMode);
$this->Lexer->addEntryPattern('\n\{\|[^\n]*',$mode, $this->pluginMode);
}
function postConnect() {
$pluginMode = 'plugin_'.$this->getPluginName();
// table end: |}
$this->Lexer->addExitPattern('[ \t]*\n\|\}', $pluginMode);
$this->Lexer->addExitPattern('[ \t]*\n\|\}', $this->pluginMode);

// match pattern for attributes
$attrs = '[^\n\{\|\!\[]+';

// caption: |+ attrs | caption
$this->Lexer->addPattern("\n\|\+ *(?:$attrs\|(?!\|))?", $pluginMode);
$this->Lexer->addPattern("\n\|\+ *(?:$attrs\|(?!\|))?", $this->pluginMode);
// table row: |- attrs
$this->Lexer->addPattern(' *?\n\|\-+[^\n]*', $pluginMode);
$this->Lexer->addPattern(' *?\n\|\-+[^\n]*', $this->pluginMode);
// table header: ! attrs |
$this->Lexer->addPattern("(?: *?\n|\!)\!(?:$attrs\|(?!\|))?", $pluginMode);
$this->Lexer->addPattern("(?: *?\n|\!)\!(?:$attrs\|(?!\|))?", $this->pluginMode);
// table data: | attrs |
$this->Lexer->addPattern("(?: *?\n|\|)\|(?:$attrs\|(?!\|))?", $pluginMode);
$this->Lexer->addPattern("(?: *?\n|\|)\|(?:$attrs\|(?!\|))?", $this->pluginMode);
}


Expand Down

0 comments on commit 5d510f6

Please sign in to comment.