[pmwiki-users] Running a function after markup processing, but before text output?

Patrick R. Michaud pmichaud at pobox.com
Mon Sep 12 09:42:43 CDT 2005

On Mon, Sep 12, 2005 at 01:10:51AM -0400, Russell Bailey wrote:
> I'd prefer to be able to do this without duplicating a lot of existing 
> PmWiki code,  since that creates extra work with upgrades.  Is there a 
> callback I'm missing,  or do I just need to write a modified 
> HandleBrowse() and replace the original in $HandleActions?

There's a callback.  Essentially you can place things in the
'closeall' segment:

    global $MarkupFrame;

    $MarkupFrame[0]['closeall']['yourname'] = '(:yourname:)';

The "closeall" array in the markup frame contains strings to be
added at the very end of processing, as part of the last pass
through the markup rules.  (This is how PmWiki makes sure that 
any tables, divs, and other structures are properly closed at 
the end.)  So, the line above would insert '(:yourname:)' at the 
very end of processing, and you can then have a custom markup rule
to process it:

    Markup('yourname', "...", '/\\(:yourname:\\)/e', "...");

However, it seems to me that this is the "hard way to do it", since
there's already a way to insert dynamic CSS information in the
page header through the $HTMLStylesFmt[] array.  For example, if 
you want to dynamically define a .wikistyle_red CSS class, you can
do it with:

    $HTMLStylesFmt[] = ".wikistyle_red { color:red; }\n";

and it'll be automatically output in the output's <head> section
as appropriate.  


More information about the pmwiki-users mailing list