* * This file and the files in syntax/ provide the syntax mode for the * divalign2 plugin. * * This work is a form from previous plugin (plugin:divalign) * by Jason Byrne. Check the wikipage for details. */ // must be run within DokuWiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) die(); if(!defined('DW_LF')) define('DW_LF',"\n"); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_divalign2_common extends DokuWiki_Syntax_Plugin { function getSort() { return 180; } function getType() { return 'formatting'; } function getAllowedTypes() { return array( 'container', 'substition', 'protected', 'disabled', 'formatting', 'paragraphs' ); } function getPType() { return 'block'; } function connectTo($mode) { } function postConnect() { } function handle($match, $state, $pos, Doku_Handler $handler){ // unpack and process $content= $match['content']; $align= $match['align']; switch ( $state ) { case DOKU_LEXER_ENTER: { break; } case DOKU_LEXER_UNMATCHED: { $handler->_addCall('cdata', array($content), $pos); break; } } return array($align,$state,$pos); } function render($mode, Doku_Renderer $renderer, $data) { list ($align, $state, $pos) = $data; if (false) { } else if (in_array($mode, ['xhtml', 's5', 'purplenumbers', 'rplus', 'html5'])) { switch ($state) { case DOKU_LEXER_ENTER: { if ($align) { $renderer->doc .= '
'; } break; } case DOKU_LEXER_EXIT : { $renderer->doc .= '
'. DW_LF; break; } } // end switch return true; } else if ($mode=='odt') { if (!method_exists ($renderer, 'getODTPropertiesFromElement')) { $this->render_odt_v1 ($renderer, $state, $align); } else { $this->render_odt_v2 ($renderer, $state, $align); } return true; } return false; } function render_odt_v1 (Doku_Renderer $renderer, $state, $align) { $Align = ucfirst ($align); //static $center_defined= false; $st = <<