[dokuwiki] Re: Is it possible to get data between states in plugins?

  • From: Chris Tapp <opensource@xxxxxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 8 Feb 2012 08:22:09 +0000

On 7 Feb 2012, at 23:04, Chris Green wrote:

A typical syntax plugin with a format like:-

   <plugin:param1=abc&param2=xyz>Some text here</plugin>

Will handle states DOKU_LEXER_ENTER, DOKU_LEXER_UNMATCHED and
DOKU_LEXER_EXIT in its handle() function, is there any way to communicate
between them?

E.g. will class variables be available between calls or is each call
of handle() in a different instance of the syntax plugin class?

Do you need the information in the handler or the renderer?

I've needed to propagate data from ENTER to EXIT when rendering in the past. I've done this by:

1) Creating a class to hold the data I need for each handler state. These are used within the return from handle();
2) Registering a PARSER_HANDLER_DONE action callback;
3) Using the above to find the [ 'plugin' ][ 'myplugin' ] [ DOKU_LEXER_ENTER ] instructions and copying the relevant data to the corresponding [ 'plugin' ][ 'myplugin' ][ DOKU_LEXER_EXIT ] instruction.

I did originally try storing information within the class but I found this was not robust.

Chris Tapp

opensource@xxxxxxxxxxxx
www.keylevel.com



--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: