beber pushed a commit to branch master.

http://git.enlightenment.org/website/www.git/commit/?id=f7a5a38b19a16b07f5d1d22a34718b13ca793a3b

commit f7a5a38b19a16b07f5d1d22a34718b13ca793a3b
Author: Bertrand Jacquin <bertr...@jacquin.bzh>
Date:   Sun Oct 15 04:49:00 2017 +0100

    MEDIUM: Update plugin exttab3 to v2016-06-19
---
 public_html/lib/plugins/exttab3/README.md         |  10 +-
 public_html/lib/plugins/exttab3/action.php        |  10 +-
 public_html/lib/plugins/exttab3/all.less          |  19 ++
 public_html/lib/plugins/exttab3/example.txt       | 100 ++++++++
 public_html/lib/plugins/exttab3/helper/odt.php    | 119 ++++++++++
 public_html/lib/plugins/exttab3/images/sample.png | Bin 15655 -> 17177 bytes
 public_html/lib/plugins/exttab3/odt.css           |  17 ++
 public_html/lib/plugins/exttab3/plugin.info.txt   |   4 +-
 public_html/lib/plugins/exttab3/style.css         |  13 --
 public_html/lib/plugins/exttab3/syntax.php        | 263 +++++++++++-----------
 10 files changed, 402 insertions(+), 153 deletions(-)

diff --git a/public_html/lib/plugins/exttab3/README.md 
b/public_html/lib/plugins/exttab3/README.md
index 75bb27d6..d10fb84b 100644
--- a/public_html/lib/plugins/exttab3/README.md
+++ b/public_html/lib/plugins/exttab3/README.md
@@ -1,12 +1,12 @@
-DokuWiki plugin ExtTab3
-=======================
+Extended Table Syntax for DokuWiki
+==================================
 
 The third trial to implement extended (MediaWiki-style) table syntax in 
DokuWiki
 
 Syntax
 ------
 
-http://www.mediawiki.org/wiki/Help:Tables
+https://www.mediawiki.org/wiki/Help:Tables
 
 | markup | description |
 |:--     |:--          |
@@ -21,6 +21,6 @@ http://www.mediawiki.org/wiki/Help:Tables
 Licensed under the GNU Public License (GPL) version 2
 
 More infomation is available:
-  * http://www.dokuwiki.org/plugin:exttab3
+  * https://www.dokuwiki.org/plugin:exttab3
 
-(c) 2014 Satoshi Sahara \<sahara.sato...@gmail.com>
+(c) 2014-2017 Satoshi Sahara \<sahara.sato...@gmail.com>
diff --git a/public_html/lib/plugins/exttab3/action.php 
b/public_html/lib/plugins/exttab3/action.php
index 7f87a0ea..9bf3878a 100644
--- a/public_html/lib/plugins/exttab3/action.php
+++ b/public_html/lib/plugins/exttab3/action.php
@@ -10,8 +10,6 @@
 
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
-require_once(DOKU_PLUGIN.'action.php');
 
 class action_plugin_exttab3 extends DokuWiki_Action_Plugin {
 
@@ -22,16 +20,16 @@ class action_plugin_exttab3 extends DokuWiki_Action_Plugin {
         $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 
'handle_toolbar', array ());
     }
 
-    public function handle_toolbar(&$event, $param) {
+    public function handle_toolbar(Doku_Event $event, $param) {
         $event->data[] = array (
             'type' => 'picker',
             'title' => 'extended table typical patterns',
-            'icon' => DOKU_BASE.'lib/plugins/exttab3/images/table.png',
+            'icon' => DOKU_REL.'lib/plugins/exttab3/images/table.png',
             'list' => array(
                 array(
                     'type'   => 'format',
                     'title'  => 'Definition table',
-                    'icon'   => DOKU_BASE.'lib/plugins/exttab3/images/d.png',
+                    'icon'   => DOKU_REL.'lib/plugins/exttab3/images/d.png',
                     'sample' => 'term',
                     'open'   => '\n{|\n|-\n! ',
                     'close'  => ' || description\n|}\n',
@@ -40,7 +38,7 @@ class action_plugin_exttab3 extends DokuWiki_Action_Plugin {
                 array(
                     'type'   => 'format',
                     'title'  => 'longer cell content',
-                    'icon'   => 
DOKU_BASE.'lib/plugins/exttab3/images/table.png',
+                    'icon'   => 
DOKU_REL.'lib/plugins/exttab3/images/table.png',
                     'sample' => 'table caption',
                     'open'   => '\n{| style=""\n|+ ',
                     'close'  => '\n!\nA1\n!\nB1\n|-\n|\nA2\n|\nB2\n|}\n',
diff --git a/public_html/lib/plugins/exttab3/all.less 
b/public_html/lib/plugins/exttab3/all.less
new file mode 100644
index 00000000..baaffd47
--- /dev/null
+++ b/public_html/lib/plugins/exttab3/all.less
@@ -0,0 +1,19 @@
+/**
+ * DokuWiki Plugin ExtTab3: all.less
+ */
+table.exttable {
+  td > p:last-child {
+    // background-color: #00ccff;
+    margin-bottom: 0;
+  }
+}
+
+table.exttable.design {
+  ul {
+    padding-left: 0em;
+  }
+  ol {
+    padding-left: 0em;
+  }
+}
+
diff --git a/public_html/lib/plugins/exttab3/example.txt 
b/public_html/lib/plugins/exttab3/example.txt
new file mode 100644
index 00000000..1add87ee
--- /dev/null
+++ b/public_html/lib/plugins/exttab3/example.txt
@@ -0,0 +1,100 @@
+====== Examples for the Extended Table ======
+[[doku>plugin:exttab3]]
+  * http://www.mediawiki.org/wiki/Help:Tables
+  * http://meta.wikimedia.org/wiki/Help:Table
+
+===== Quick example =====
+<WRAP col2>
+=== Source Text===
+<file>
+{| title="Extended Table Example"
+|+//Extended Table Example//
+! style="width: 12em;"| A1 Header
+! style="width: 10em;"| B1 Header
+|- style="background-color: MistyRose;"
+|
+{| title="nested table"
+|+ //nested table//
+|
+{{ wiki:dokuwiki-128.png?50&nolink}}
+**Lorem** ipsum dolor sit amet, 
+//consetetur// sadipscing elitr, 
+sed diam nonumy eirmod tempor invidunt
+ut labore et dolore magna aliquyam erat, 
+sed diam voluptua.
+|}
+|
+List in Cell
+  * //italic// and **bold**
+  * ''monospace''
+  * [[:start|page link]]
+
+> quoting
+
+**ATTENTION:**\\
+Needs an extra empty line 
+after lists and quoting syntax!
+|}
+</file>
+
+=== Visual Output ===
+{| title="Extended Table Example"
+|+//Extended Table Example//
+! style="width: 12em;"| A1 Header
+! style="width: 10em;"| B1 Header
+|- style="background-color: MistyRose;"
+|
+{| title="nested table"
+|+ //nested table//
+|
+{{ wiki:dokuwiki-128.png?50&nolink}}
+**Lorem** ipsum dolor sit amet, 
+//consetetur// sadipscing elitr, 
+sed diam nonumy eirmod tempor invidunt
+ut labore et dolore magna aliquyam erat, 
+sed diam voluptua.
+|}
+|
+List in Cell
+  * //italic// and **bold**
+  * ''monospace''
+  * [[:start|page link]]
+
+> quoting
+
+**ATTENTION:**\\
+Needs an extra empty line 
+after lists and quoting syntax!
+|}
+</WRAP> /* col2 */
+
+
+\\
+===== Sections in Table =====
+<WRAP col2>
+=== Source Text===
+<file>
+{| title="Example : Using Section markup in Table" 
+|
+<WRAP info>[[doku>plugin:wrap]] box
+====Sections in Wrap block====
+The headline will be shown in TOC.
+</WRAP>
+===== Sections in a Cell =====
+
+Section markup does not work.
+|}
+</file>
+
+=== Visual Output ===
+{| title="Example : Using Section markup in Table" 
+|
+<WRAP info>[[doku>plugin:wrap]] box
+====Sections in Wrap block====
+The headline will be shown in TOC.
+</WRAP>
+===== Sections in a Cell =====
+
+Section markup does not work.
+|}
+</WRAP>
diff --git a/public_html/lib/plugins/exttab3/helper/odt.php 
b/public_html/lib/plugins/exttab3/helper/odt.php
new file mode 100644
index 00000000..2f07d2b4
--- /dev/null
+++ b/public_html/lib/plugins/exttab3/helper/odt.php
@@ -0,0 +1,119 @@
+<?php
+/**
+ * ODT (Open Document format) export for Exttab3 plugin
+ * 
+ * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author     Lars (LarsDW223)
+ */
+
+if(!defined('DOKU_INC')) die();
+
+class helper_plugin_exttab3_odt extends DokuWiki_Plugin {
+
+    function render(Doku_Renderer $renderer, $data) {
+        $properties = array();
+
+        // Return if installed ODT plugin version is too old.
+        if ( method_exists($renderer, 'getODTProperties') == false ||
+             method_exists($renderer, '_odtTableAddColumnUseProperties') == 
false ) {
+            return false;
+        }
+
+        //list($tag, $state, $match) = $data;
+        list($state, $tag, $attr) = $data;
+
+        // Get style content
+        $style = '';
+        if (preg_match('/style=".*"/', $attr, $matches) === 1) {
+            $style = substr($matches[0], 6);
+            $style = trim($style, ' "');
+        }
+
+        // class to get CSS Properties by $render->getODTProperties()
+        $class = 'exttable';
+
+        switch ( $state ) {
+            case DOKU_LEXER_ENTER:    // open tag
+                if (!class_exists('ODTDocument')) {
+                    // Code for backwards compatibility to older ODT versions
+                    // Get CSS properties for ODT export.
+                    $renderer->getODTProperties($properties, $tag, $class, 
$style);
+
+                    switch ($tag) {
+                        case 'table':
+                            $renderer->_odtTableOpenUseProperties($properties);
+                            break;
+                        case 'caption':
+                            // There is no caption in ODT table format.
+                            // So we emulate it by creating a header row 
spaning over all columns.
+                            
$renderer->_odtTableRowOpenUseProperties($properties);
+
+                            // Parameter 'colspan=0' indicates span across all 
columns!
+                            
$renderer->_odtTableHeaderOpenUseProperties($properties, 0, 1);
+                            break;
+                        case 'th':
+                            
$renderer->_odtTableHeaderOpenUseProperties($properties);
+                            
$renderer->_odtTableAddColumnUseProperties($properties);
+                            break;
+                        case 'tr':
+                            
$renderer->_odtTableRowOpenUseProperties($properties);
+                            break;
+                        case 'td':
+                            
$renderer->_odtTableCellOpenUseProperties($properties);
+                            break;
+                    }
+                } else {
+                    switch ($tag) {
+                        case 'table':
+                            $renderer->_odtTableOpenUseCSS(NULL, NULL, $tag, 
$attr);
+                            break;
+                        case 'caption':
+                            // There is no caption in ODT table format.
+                            // So we emulate it by creating a header row 
spaning over all columns.
+                            $renderer->_odtTableRowOpenUseCSS($tag, $attr);
+
+                            // Parameter 'colspan=0' indicates span across all 
columns!
+                            $renderer->_odtTableHeaderOpenUseCSS(0, 1, $tag, 
$attr);
+                            break;
+                        case 'th':
+                            $renderer->_odtTableHeaderOpenUseCSS(1, 1, $tag, 
$attr);
+                            break;
+                        case 'tr':
+                            $renderer->_odtTableRowOpenUseCSS($tag, $attr);
+                            break;
+                        case 'td':
+                            $renderer->_odtTableCellOpenUseCSS(1, 1, $tag, 
$attr);
+                            break;
+                    }
+                }
+                break;
+            case DOKU_LEXER_MATCHED:  // defensive, shouldn't occur
+                break;
+            case DOKU_LEXER_UNMATCHED:
+                $renderer->cdata($tag);
+                break;
+            case DOKU_LEXER_EXIT:     // close tag
+                switch ($tag) {
+                    case 'table':
+                        //$renderer->table_close();
+                        $renderer->_odtTableClose();
+                        break;
+                    case 'caption':
+                        $renderer->tableheader_close();
+                        $renderer->tablerow_close();
+                        break;
+                    case 'th':
+                        $renderer->tableheader_close();
+                        break;
+                    case 'tr':
+                        $renderer->tablerow_close();
+                        break;
+                    case 'td':
+                        $renderer->p_close();
+                        $renderer->tablecell_close();
+                        break;
+                }
+                break;
+        }
+    }
+}
diff --git a/public_html/lib/plugins/exttab3/images/sample.png 
b/public_html/lib/plugins/exttab3/images/sample.png
index 478681e8..981ff7df 100644
Binary files a/public_html/lib/plugins/exttab3/images/sample.png and 
b/public_html/lib/plugins/exttab3/images/sample.png differ
diff --git a/public_html/lib/plugins/exttab3/odt.css 
b/public_html/lib/plugins/exttab3/odt.css
new file mode 100644
index 00000000..ca6ce502
--- /dev/null
+++ b/public_html/lib/plugins/exttab3/odt.css
@@ -0,0 +1,17 @@
+/********************************************************************
+ODT-Export Styles for the Exttab3 Plugin
+********************************************************************/
+
+.exttable th {
+    border: 1pt solid __border__;
+    padding: 0.5em;
+    background-color: __background_alt__;
+    color: __text__;
+    font-weight:bold;
+}
+
+.exttable td {
+    border: 1pt solid __border__;
+    padding: 0.5em;
+}
+
diff --git a/public_html/lib/plugins/exttab3/plugin.info.txt 
b/public_html/lib/plugins/exttab3/plugin.info.txt
index d2280aea..0928a126 100644
--- a/public_html/lib/plugins/exttab3/plugin.info.txt
+++ b/public_html/lib/plugins/exttab3/plugin.info.txt
@@ -1,7 +1,7 @@
 base   exttab3
 author Satoshi Sahara
 email  sahara.sato...@gmail.com
-date   2014-11-20
+date   2016-06-19
 name   Extended Table Syntax 3
-desc   Allows extended (MediaWiki-style) tables inside DokuWiki
+desc   Allows extended (MediaWiki-style) table syntax in DokuWiki
 url    https://www.dokuwiki.org/plugin:exttab3
diff --git a/public_html/lib/plugins/exttab3/style.css 
b/public_html/lib/plugins/exttab3/style.css
deleted file mode 100644
index 5c9e2d25..00000000
--- a/public_html/lib/plugins/exttab3/style.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * DokuWiki Plugin ExtTab3 style.css
- */
-div.exttab p {
-    margin-bottom: 0;
-}
-div.exttab ol {
-    padding-left: 0em;
-}
-div.exttab ul {
-    padding-left: 0em;
-}
-
diff --git a/public_html/lib/plugins/exttab3/syntax.php 
b/public_html/lib/plugins/exttab3/syntax.php
index d1ff7c46..f0d4cfc4 100644
--- a/public_html/lib/plugins/exttab3/syntax.php
+++ b/public_html/lib/plugins/exttab3/syntax.php
@@ -6,47 +6,48 @@
  *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Satoshi Sahara <sahara.sato...@gmail.com>
- * @date       2014-11-20
  */
  
 // must be run within Dokuwiki
 if(!defined('DOKU_INC')) die();
-if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
-require_once(DOKU_PLUGIN.'syntax.php');
  
 class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {
 
+    protected $mode;
     protected $stack = array();  // stack of current open tag - used by 
handle() method
-    protected $tableDepth;       // table depth counter
     protected $tagsmap  = array();
     protected $attrsmap = array();
 
     function __construct() {
-        $this->tableDepth = 0;
+        $this->mode = substr(get_class($this), 7);
 
         // define name, prefix and postfix of tags
         $this->tagsmap = array(
-                'table'   => array("", "\n" ),        // table start  : {|
-                '/table'  => array("", ""),           // table end    : |}
-                'caption' => array("\t", "\n" ),      // caption      : |+
-                'tr'      => array("\t", "\n" ),      // table row    : |-
-                'th'      => array("\t"."\t", "\n" ), // table header : !
-                'td'      => array("\t"."\t", "\n" ), // table data   : |
-                'div'     => array("", "\n" ),        // wrapper
+                'table'    => array("", "\n" ),     // table start  : {|
+                '/table'   => array("", "\n"),      // table end    : |}
+                'caption'  => array("", ""),        // caption      : |+
+                '/caption' => array("", "\n"),
+                'tr'       => array("", "\n"),      // table row    : |-
+                '/tr'      => array("", "\n"),
+                'th'       => array("", ""),        // table header : !
+                '/th'      => array("", "\n"),
+                'td'       => array("", ""),        // table data   : |
+                '/td'      => array("", "\n"),
         );
 
         // define allowable attibutes for table tags
         $this->attrsmap = array(
-            # simple ones (value is a single word)
-            'align', 'border', 'cellpadding', 'cellspacing', 'frame', 
-            'rules', 'width', 'class', 'dir', 'id', 'lang', 'xml:lang',
-            # more complex ones (value is a string or style)
-            'bgcolor', 'summary', 'title', 'style',
-            # additional tr, thead, tbody, tfoot attributes
-            'char', 'charoff', 'valign',
-            # additional td attributes
-            'abbr', 'colspan', 'axis', 'headers', 'rowspan', 'scope',
-            'height', 'width', 'nowrap',
+            # html5 HTML Global Attributes
+            'accesskey', 'class', 'contenteditable', 'contextmenu',
+            'dir', 'draggable', 'dropzone', 'hidden', 'id', 'lang',
+            'spellcheck', 'style', 'tabindex', 'title', 'translate',
+            'xml:lang',
+            # html5 table tag
+            'border', 'sortable',
+            # html5 th and td tag
+            'abbr', 'colspan', 'headers', 'rowspan', 'scope', 'sorted',
+            # deprecated in html5
+            'align', 'valign', 'width', 'height', 'bgcolor', 'nowrap',
         );
     }
 
@@ -54,7 +55,12 @@ class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {
     function getPType(){ return 'block';}
     function getSort(){  return 59; } // = Doku_Parser_Mode_table-1
     function getAllowedTypes() { 
-        return array('container', 'formatting', 'substition', 'disabled', 
'protected'); 
+        return array('container', 'formatting', 'substition', 'disabled', 
'protected', 'paragraphs');
+    }
+    // override default accepts() method to allow nesting
+    public function accepts($mode) {
+        if ($mode == $this->mode) return true;
+        return parent::accepts($mode);
     }
 
     /**
@@ -62,28 +68,24 @@ class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {
      * modified from original exttab2 code
      */
     function connectTo($mode) {
-        $pluginMode = 'plugin_'.$this->getPluginName();
-        $this->Lexer->addEntryPattern('\n\{\|[^\n]*',$mode, $pluginMode); 
+        // table start:  {| attrs
+        $this->Lexer->addEntryPattern('\n\{\|[^\n]*',$mode, $this->mode);
     }
     function postConnect() {
-        $pluginMode = 'plugin_'.$this->getPluginName();
-        $attrs = '[^\n\{\|\!\[]+'; // match pattern for attributes
+        // table end:    |}
+        $this->Lexer->addExitPattern('[ \t]*\n\|\}', $this->mode);
 
-        // terminale = Exit Pattren: table end markup + extra brank line
-        $this->Lexer->addExitPattern(' *?\n\|\}(?=\n\n)', $pluginMode);
+        // match pattern for attributes
+        $attrs = '[^\n\{\|\!\[]+';
 
         // caption:      |+ attrs | caption
-        $this->Lexer->addPattern("\n\|\+ *(?:$attrs\|(?!\|))?", $pluginMode);
+        $this->Lexer->addPattern("\n\|\+ *(?:$attrs\|(?!\|))?", $this->mode);
         // table row:    |- attrs
-        $this->Lexer->addPattern(' *?\n\|\-+[^\n]*', $pluginMode);
-        // table start:  {| attrs
-        $this->Lexer->addPattern(' *?\n\{\|[^\n]*', $pluginMode);
-        // table end:    |}
-        $this->Lexer->addPattern(' *?\n\|\}', $pluginMode);
+        $this->Lexer->addPattern(' *?\n\|\-+[^\n]*', $this->mode);
         // table header: ! attrs |
-        $this->Lexer->addPattern("(?: *?\n|\!)\!(?:$attrs\|(?!\|))?", 
$pluginMode);
+        $this->Lexer->addPattern("(?: *?\n|\!)\!(?:$attrs\|(?!\|))?", 
$this->mode);
         // table data:   | attrs |
-        $this->Lexer->addPattern("(?: *?\n|\|)\|(?:$attrs\|(?!\|))?", 
$pluginMode);
+        $this->Lexer->addPattern("(?: *?\n|\|)\|(?:$attrs\|(?!\|))?", 
$this->mode);
     }
 
 
@@ -91,162 +93,165 @@ class syntax_plugin_exttab3 extends 
DokuWiki_Syntax_Plugin {
      * helper function to simplify writing plugin calls to the instruction list
      * first three arguments are passed to function render as $data
      */
-    protected function _writeCall($tag, $attr, $state, $pos, $match, 
&$handler) {
+    protected function _writeCall($tag, $attr, $state, $pos, $match, $handler) 
{
         $handler->addPluginCall($this->getPluginName(),
             array($state, $tag, $attr), $state, $pos, $match);
     }
 
+    protected function _open($tag, $attr, $pos, $match, $handler) {
+        $this->_writeCall($tag,$attr,DOKU_LEXER_ENTER, $pos,$match,$handler);
+    }
+
+    protected function _close($tag, $pos, $match, $handler) {
+        $this->_writeCall($tag,'',DOKU_LEXER_EXIT, $pos,$match,$handler);
+    }
+
     /**
      * helper function for exttab syntax translation to html
      *
      * @param string $match       matched string
-     * @return array              tag name, and attributes
+     * @return array              tag name and attributes
      */
-    protected function _resolve_markup($match='') {
-        $markup = substr(trim($match), 0, 2);
-        if ($markup       == '{|') { // table_start
-            return array('table', substr($match, 2));
-        } elseif ($markup == '|}') { // table_end
-            return array('/table', '');
-        } elseif ($markup == '|+') { // table_caption
-            return array('caption', trim(substr($match, 2), '|'));
-        } elseif ($markup == '|-') { // table_row
-            return array('tr', trim(substr($match, 2), '-'));
+    protected function _interpret($match='') {
+        $markup = ltrim($match);
+        $len = 2;
+        switch (substr($markup, 0, $len)) {
+            case '{|': $tag = 'table';   break;
+            case '|}': $tag = '/table';  break;
+            case '|+': $tag = 'caption'; break;
+            case '|-': $tag = 'tr';      break;
+            case '||': $tag = 'td';      break;
+            case '!!': $tag = 'th';      break;
+            default:
+                $len = 1;
+                switch (substr($markup, 0, $len)) {
+                    case '!': $tag = 'th'; break;
+                    case '|': $tag = 'td'; break;
+                }
         }
-        $markup = substr(trim($match), 0, 1);
-        if ($markup       == '!') {  // table_header
-            return array('th', trim($match, '!|'));
-        } elseif ($markup == '|') {  // table_data
-            return array('td', trim($match, '|'));
+        if (isset($tag)) {
+            $attrs = substr($markup, $len);
+            return array($tag, $attrs);
         } else {
-            msg($this->getPluginName().' ERROR: unknown syntax: '.hsc($match) 
,-1);
+            msg($this->getPluginName().' ERROR: unknown syntax: '.hsc($markup) 
,-1);
             return false;
         }
     }
 
+    /**
+     * append specified class name to attributes
+     *
+     * @param string $class       class name
+     * @param string $attr        attributes of html tag
+     * @return string             modified $attr
+     */
+    private function _appendClass($class, $attr) {
+        $regex = "/\b(?:class=\")(.*?\b($class)?\b.*?)\"/";
+        preg_match($regex, $attr, $matches);
+        if ($matches[2]) {
+            // $class found in the class attribute
+            return $attr;
+        } elseif (empty($matches[0])) {
+            // class attribute is not specified
+            return $attr.' class="'.$class.'"';
+        } else {
+            // class attribute is specified, but include $class
+            $items = explode(' ',$matches[1]);
+            $items[] = $class;
+            $replace = '$class="'.implode(' ',$items).'"';
+            return str_replace($matches[0], $replace, $attr);
+        }
+    }
+
 
     /**
      * Handle the match
      */
     function handle($match, $state, $pos, Doku_Handler $handler) {
 
-        // msg('handle: state='.$state.' 
match="'.str_replace("\n","_",$match).'"', 0);
+        //error_log('ExtTable handle: state='.$state.' 
match="'.str_replace("\n","_",$match).'"');
 
         switch ($state) {
             case DOKU_LEXER_ENTER:
-                // wrapper open
-                $this->_writeCall('div', 'class="exttab"', DOKU_LEXER_ENTER, 
$pos,$match,$handler);
                 // table start
-                list($tag, $attr) = $this->_resolve_markup($match);
+                list($tag, $attr) = $this->_interpret($match);
+                // ensure that class attribute cotains "exttable"
+                $attr = $this->_appendClass('exttable', $attr);
                 array_push($this->stack, $tag);
-                $this->_writeCall($tag, $attr, DOKU_LEXER_ENTER, 
$pos,$match,$handler);
-                $this->tableDepth = $this->tableDepth +1; // increment table 
depth counter
+                $this->_open($tag, $attr, $pos,$match,$handler);
+                break;
+            case DOKU_LEXER_EXIT:
+                do { // rewind table
+                    $oldtag = array_pop($this->stack);
+                    $this->_close($oldtag, $pos,$match,$handler);
+                } while ($oldtag != 'table');
                 break;
             case DOKU_LEXER_MATCHED:
                 $tag_prev = end($this->stack);
-                list($tag, $attr) = $this->_resolve_markup($match);
+                list($tag, $attr) = $this->_interpret($match);
                 switch ($tag_prev) {
                     case 'caption':
                                 $oldtag = array_pop($this->stack);
-                                $this->_writeCall($oldtag,'',DOKU_LEXER_EXIT, 
$pos,$match,$handler);
+                                $this->_close($oldtag, $pos,$match,$handler);
                     case 'table':
                         switch ($tag) {
-                            case 'table':
-                                msg($this->getPluginName().' Syntax ERROR: 
match='.hsc($match) ,-1);
-                                break;
                             case 'caption':
                             case 'tr':
                                 array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
+                                $this->_open($tag, $attr, 
$pos,$match,$handler);
                                 break;
                             case 'th':
                             case 'td':
                                 array_push($this->stack, 'tr');
-                                $this->_writeCall('tr', '', DOKU_LEXER_ENTER, 
$pos,$match,$handler);
+                                $this->_open('tr', '', $pos,$match,$handler);
                                 array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
-                                break;
-                            case '/table':
-                                array_pop($this->stack);
-                                $this->_writeCall('table', '', 
DOKU_LEXER_EXIT, $pos,$match,$handler);
-                                $this->tableDepth = $this->tableDepth -1;
+                                $this->_open($tag, $attr, 
$pos,$match,$handler);
                                 break;
                         }
                         break;
                     case 'tr':
                         switch ($tag) {
-                            case 'table':
                             case 'caption':
-                                msg($this->getPluginName().' Syntax ERROR: 
match='.hsc($match) ,-1);
+                                msg($this->getPluginName().' Syntax ERROR: 
match='.hsc(trim($match)) ,-1);
                                 break;
                             case 'tr':
                                 $oldtag = array_pop($this->stack);
-                                $this->_writeCall($oldtag, '', 
DOKU_LEXER_EXIT, $pos,$match,$handler); 
+                                $this->_close($oldtag, $pos,$match,$handler);
                                 array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
+                                $this->_open($tag, $attr, 
$pos,$match,$handler);
                                 break;
                             case 'th':
                             case 'td':
                                 array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
-                                break;
-                            case '/table':
-                                do { // rewind table
-                                    $oldtag = array_pop($this->stack);
-                                    
$this->_writeCall($oldtag,'',DOKU_LEXER_EXIT, $pos,$match,$handler);
-                                } while ($oldtag != 'table');
-                                $this->tableDepth = $this->tableDepth -1;
+                                $this->_open($tag, $attr, 
$pos,$match,$handler);
                                 break;
                         }
                         break;
                     case 'th':
                     case 'td':
                         switch ($tag) {
-                            case 'table':   // a table within a table
-                                array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
-                                $this->tableDepth = $this->tableDepth +1;
-                                break;
                             case 'caption':
-                                msg($this->getPluginName().' Syntax ERROR: 
match='.hsc($match) ,-1);
+                                msg($this->getPluginName().' Syntax ERROR: 
match='.hsc(trim($match)) ,-1);
                                 break;
                             case 'tr':
                                 do { // rewind old row prior to start new row
                                     $oldtag = array_pop($this->stack);
-                                    
$this->_writeCall($oldtag,'',DOKU_LEXER_EXIT, $pos,$match,$handler);
+                                    $this->_close($oldtag, 
$pos,$match,$handler);
                                 } while ($oldtag != 'tr');
                                 array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
+                                $this->_open($tag, $attr, 
$pos,$match,$handler);
                                 break;
                             case 'th':
                             case 'td':
                                 $oldtag = array_pop($this->stack);
-                                $this->_writeCall($oldtag,'',DOKU_LEXER_EXIT, 
$pos,$match,$handler); 
+                                $this->_close($oldtag, $pos,$match,$handler);
                                 array_push($this->stack, $tag);
-                                $this->_writeCall($tag, $attr, 
DOKU_LEXER_ENTER, $pos,$match,$handler);
-                                break;
-                            case '/table':
-                                do { // rewind table
-                                    $oldtag = array_pop($this->stack);
-                                    
$this->_writeCall($oldtag,'',DOKU_LEXER_EXIT, $pos,$match,$handler);
-                                } while ($oldtag != 'table');
-                                $this->tableDepth = $this->tableDepth -1;
+                                $this->_open($tag, $attr, 
$pos,$match,$handler);
                                 break;
                         }
                         break;
                 }
                 break;
-            case DOKU_LEXER_EXIT:
-                if ($this->tableDepth > 1) {
-                    msg($this->getPluginName().': missing table end markup 
"|}" '.$this->tableDepth, -1);
-                }
-                while ($tag = array_pop($this->stack)) {
-                    $this->_writeCall($tag,'',DOKU_LEXER_EXIT, 
$pos,$match,$handler);
-                }
-                $this->tableDepth = 0;
-                // wrapper close
-                $this->_writeCall('div', '', DOKU_LEXER_EXIT, 
$pos,$match,$handler);
-                break;
             case DOKU_LEXER_UNMATCHED:
                 $tag_prev = end($this->stack);
                 switch ($tag_prev) {
@@ -256,10 +261,10 @@ class syntax_plugin_exttab3 extends 
DokuWiki_Syntax_Plugin {
                                 break;
                     case 'table':
                                 array_push($this->stack, 'tr');
-                                $this->_writeCall('tr','',DOKU_LEXER_ENTER, 
$pos,$match,$handler);
+                                $this->_open('tr','', $pos,$match,$handler);
                     case 'tr':
                                 array_push($this->stack, 'td');
-                                $this->_writeCall('td','',DOKU_LEXER_ENTER, 
$pos,$match,$handler);
+                                $this->_open('td','', $pos,$match,$handler);
                     case 'th':
                     case 'td':
                                 // cdata --- use base() instead of 
$this->_writeCall()
@@ -278,31 +283,35 @@ class syntax_plugin_exttab3 extends 
DokuWiki_Syntax_Plugin {
         if (empty($data)) return false;
 
         switch ($format) {
-            case 'xhtml' : return $this->render_xhtml($renderer, $data);
+            case 'xhtml' :
+                return $this->render_xhtml($renderer, $data);
+            case 'odt'   :
+                $odt = $this->loadHelper('exttab3_odt');
+                return $odt->render($renderer, $data);
             default:
-                return true;
+                return false;
         }
-        return false;
     }
 
-    protected function render_xhtml(&$renderer, $data) {
+    protected function render_xhtml(Doku_Renderer $renderer, $data) {
         //list($tag, $state, $match) = $data;
         list($state, $tag, $attr) = $data;
 
         switch ( $state ) {
             case DOKU_LEXER_ENTER:    // open tag
-                $renderer->doc.= $this->_open($tag, $attr);
+                $renderer->doc.= $this->_tag_open($tag, $attr);
                 break;
             case DOKU_LEXER_MATCHED:  // defensive, shouldn't occur
             case DOKU_LEXER_UNMATCHED:
                 $renderer->cdata($tag);
                 break;
             case DOKU_LEXER_EXIT:     // close tag
-                $renderer->doc.= $this->_close($tag);
+                $renderer->doc.= $this->_tag_close($tag);
                 break;
         }
     }
 
+
     /**
      * open a exttab tag, used by render_xhtml()
      *
@@ -310,7 +319,7 @@ class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {
      * @param  string $attr       attibutes of tag element
      * @return string             html used to open the tag
      */
-    protected function _open($tag, $attr=NULL) {
+    protected function _tag_open($tag, $attr=NULL) {
         $before = $this->tagsmap[$tag][0];
         $after  = $this->tagsmap[$tag][1];
         $attr = $this->_cleanAttrString($attr, $this->attrsmap);
@@ -323,9 +332,9 @@ class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {
      * @param  string $tag        'table','caption','tr','th' or 'td'
      * @return string             html used to close the tag
      */
-    protected function _close($tag) {
-        $before = $this->tagsmap[$tag][0];
-        $after  = $this->tagsmap[$tag][1];
+    protected function _tag_close($tag) {
+        $before = $this->tagsmap['/'.$tag][0];
+        $after  = $this->tagsmap['/'.$tag][1];
         return $before.'</'.$tag.'>'.$after;
     }
 
@@ -354,7 +363,7 @@ class syntax_plugin_exttab3 extends DokuWiki_Syntax_Plugin {
      * some safe stuff, but better safe than sorry.)
      * NOTE: Attribute values MUST be in quotes now.
      */
-    function _cleanAttrString($attr='', $allowed_keys) {
+    protected function _cleanAttrString($attr='', $allowed_keys) {
         if (is_null($attr)) return NULL;
         # Keep spaces simple
         $attr = trim(preg_replace('/\s+/', ' ', $attr));

-- 


Reply via email to