Compatible with DokuWiki
Rincewind
The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Similar to replace
The Code was adapted from replace.
This Plugin creates a syntax-plugin for each row in your config-file.
The Plugin uses the config-file to create syntax_plugins dynamically. The File consists of three columns:
# inhaltsverzeichnisse \@toc\:[^\r\n!]*[!|\r?\n] \@toc\:([^\r\n!]*)!? {{topic>${1}}} # tagcloud \@cloud[^\r\n]*[\r\n?|\n] \@cloud([^\r\n]*) ~~TAGCLOUD${1}~~ # no-cache-feature \@nocache[\r\n?|\n] \@nocache ~~NOCACHE~~ # set tags \@tags\:[^\r\n]*[\r\n?|\n] \@tags\:([^\r\n]*) {{tag>${1}}} # include template \@tpl\:[^\r\n]*[\r\n?|\n] \@tpl\:([^\r\n]*) {{template>${1}}}@info: Eingebettet aus //[[${1}]]//* # newpage-helper \@newpage[\r\n?|\n] \@newpage {{NEWPAGE>}} \@newpage\:[^\r\n]*[\r\n?|\n] \@newpage\:([^\r\n]*) {{NEWPAGE>${1}}} # workflow easing \@fixme\:[^\r\n]*[\r\n?|\n] \@fixme\:([^\r\n]*) <wrap>FIXME ${1}{{tag>todo fixme}}</wrap> # simple info-frame \@info\:[^\r\n]*[\r\n?|\n] \@info\:([^\r\n]*) <wrap info>${1}</wrap>
<?php /** * Plugin modMLU: regular expressions to generate a standarized wiki-syntax. */ if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); class Syntax_Plugin_modMLU extends DokuWiki_Syntax_Plugin { public static $subs=0; protected static $modMLUconf; public static $classDir; protected $realClassName = 'wiki mods @ mlu'; function getInfo() { return array( 'author' => 'Robert Jäckel', 'email' => 'robert.jaeckel@verwaltung.uni-halle.de', 'date' => '2012-01-12', 'name' => $this->realClassName, 'desc' => 'Anpassungen des Wikis an der MLU Halle-Wittenberg', 'url' => 'http://verwaltung.uni-halle.de', ); } function getType() { return 'substition'; } function getAllowedTypes() { return array('container','substition','protected','disabled','formatting','paragraphs'); } function render($mode, &$renderer, $data) { return true; } function getSort() { return 999; } function generateReplaceClass($setup/*=array($pattern,$search,$replace)*/) { $dir = self::$classDir.'modMLU_'.($idx=static::$subs++); @mkdir($dir); $file = $dir.'\\syntax.php'; $fHandle = fopen($file,'w+'); $generateStr = "<?php \r\n"; $generateStr .="// file: $file\r\n\r\n"; $generateStr .="// this file was generated automatically by modMLU-Syntax-Plugin\r\n\r\n"; $generateStr .='if(!defined(\'DOKU_INC\')) define(\'DOKU_INC\',realpath(dirname(__FILE__).\'/../../\').\'/\');if(!defined(\'DOKU_PLUGIN\')) define(\'DOKU_PLUGIN\',DOKU_INC.\'lib/plugins/\');'; $generateStr .='require_once(\''.__FILE__."');\r\n\r\n"; $generateStr .= 'class Syntax_Plugin_modMLU_'.$idx.' extends '.get_class($this)."{\r\n"; foreach($setup as $k=>$v) $generateStr.='protected $'.$k.' = \''.str_replace('\'','\\\'',$v)."';\r\n"; $generateStr .= 'protected $subIDX='.$idx.";\r\n}\r\n\r\n"; fwrite($fHandle,$generateStr); fclose($fHandle); return $idx; // generate subclass } function Syntax_Plugin_modMLU() { //read cfg-file and create subclasses if(isset(self::$modMLUconf)) return true; self::$classDir = dirname(__FILE__).'\\..\\'; $cfg = self::$modMLUconf = confToHash(DOKU_CONF . 'replaceMLU.conf'); $requires = ''; foreach($cfg as $pMatch=>$sAction) { $aAction = explode("\t",$sAction,2); $idx=$this->generateReplaceClass(array('pattern'=>$pMatch,'search'=>$aAction[0],'replace'=>$aAction[1],'realClassName'=>$this->realClassName.'_'.self::$subs)); } } function connectTo($mode) { if(!$this->pattern) return; $this->Lexer->addSpecialPattern($this->pattern,$mode, 'plugin_modMLU_'.$this->subIDX); //check for search string else return } function handle($match, $state, $pos, &$handler) { if ($this->nesting) { $handler->_addCall('cdata', array($match), $pos); } else { $this->nesting = true; $nestedWriter = & new Doku_Handler_Nest($handler->CallWriter); $handler->CallWriter = & $nestedWriter; /* add magic here */ $this->Lexer->parse(preg_replace('/'.$this->search.'/',$this->replace,$match)." \\\\ "); $nestedWriter->process(); $handler->CallWriter = & $nestedWriter->CallWriter; $handler->calls[count($handler->calls) - 1][2] = $pos; $this->nesting = false; } return false; } }