[Pmwiki-users] Overwriting page

Patrick R. Michaud pmichaud
Thu Jul 8 08:08:45 CDT 2004


On Thu, Jul 08, 2004 at 08:13:56AM -0500, Philip Mateescu wrote:
> I actually wanted to do it on regular view. Let's say the user creates 
> the following page:
> -----
> Weather: Zip=77339
> Stocks: Name=^IXIC ^DJI
> Local Headlines: City=Houston,TX
> -----
> 
> I'd like to "intercept" pmwiki's render and overwrite the above text with:
> -----
> Weather: it's 88F in [[http://... Kingwood, TX]]
> Stocks: [[http://... NASDAQ]]: 1966.08 (up 0.2%) DOW J 10240.29 (down 0.3%)
> Local Headlines: ...
> ------

$DoubleBrackets is what you're looking for.  You can do something like:

    $DoubleBrackets['/Weather:\\sZip=(\\d+)/e'] = "Weather('$1')";

where Weather() is a function that returns the string you want to replace
the text that matches the regexp.  For example, a trivial weather function
might look like:

    function Weather($zip) {
      return "Weather: it's 88F in [[http://... Kingwood, TX]]";
    }

Note that $DoubleBrackets entries are processed before link processing,
so markups such as [[...]] and WikiWords still get processed before
output.  However, $DoubleBrackets occurs after processing of [=...=],
so if you want to preserve any text from being processed you have to
do so directly by using the Keep() function.

This is described in slightly more detail at 
http://www.pmwiki.org/wiki/PmWiki/CustomMarkup.

Hope this helps,

Pm




More information about the pmwiki-users mailing list