[Pmwiki-users] weird results from doublebrackets extension

Patrick R. Michaud pmichaud
Thu Nov 4 13:00:50 CST 2004


On Thu, Nov 04, 2004 at 11:31:05AM -0800, Paul Williams wrote:
> The syntax for the graphviz extension looks like this:
> =graphviz [=
> digraph G {
> 	foo->bar;
> 	foo->baz;
> }
> =]
> However, if I do anything at all to the $dot variable, I get some very 
> suprising
> results:
> 
> function graphviz( $dot) {
> 	print_r( $dot)
> }
> 
> shows
> 
> ?1?

PmWiki takes anything in [=...=] and converts it into a tokenized format
(via Keep()) so that it won't be manipulated until it is output.  You're 
wanting to get to that internal storage format, so you'll probably want
to do something like:

function graphviz($dot) {
  global $KPV,$KeepToken;
  $dot = preg_replace("/$KeepToken(\\d+?)$KeepToken/e",'$KPV[$1]',$dot);
  // process rest of $dot here
  // ...
}

The preg_replace(...) line converts the tokenized Keep string back into
whatever was inside of the [=...=].

Pm



More information about the pmwiki-users mailing list