[dokuwiki] Plugin system update notice

  • From: Christopher Smith <chris@xxxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 13 Aug 2008 13:51:54 +0100

Hi,

I'm about to push patches for a couple of plugin system updates through to Andi, the first of which may well effect existing syntax plugins. If it does, please yell so we can sort things out.

(1) Change the syntax plugin handle() function to allow it to return false when there is no need to create a plugin render instruction for that particular match. Potentially this could impact plugins which return false as real data. If false is a problem value, null is a possible alternative.

This is primarily an efficiency change. It removes unnecessary rendering instructions from the instruction list.

I will be using it to shift handling of DOKU_LEXER_UNMATCHED matches from my plugins to the standard cdata handler.

e.g.

    function handle($match, $state, $pos, &$handler){
        switch ($state) {

        ...

          case DOKU_LEXER_UNMATCHED :
            $handler->_addCall('cdata',array($match), $pos);
            return false;

        ...

This ensures unmatched (generally plain text) content will be available to render plugins that support alternate output formats via the export command.

E.g. for pages which use the box plugin, the box content may be passed to the box plugin as unmatched (those fragments of text not in another syntax mode). As the box plugin only handles 'xhtml' rendering it does nothing with that content for any other render format. If the same wiki page is exported to OpenDocument format (using odt plugin) then the box and its content will not show up. By sending the unmatched content to cdata the content will appear (although not in a box). Since the plugin is no longer required to render this content, there is no point in making a plugin call.

(2) Add an optional third parameter, $new, to the plugin_load() function.

@param $new bool true to return a new instance of the plugin, false to use an already loaded instance
function &plugin_load($type,$name,$new=false)

This is particularly important for render plugins which maintain their state in internal variables and may also be called in a nested fashion. Where DokuWiki internally uses syntax, action and admin plugins it will continue to load/use them as singletons.


As mentioned above, please comment if you believe either of these will affect you.

- Chris






--
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts: