[Pmwiki-users] Re: PmWiki 2 questions

Patrick R. Michaud pmichaud
Mon Sep 20 08:27:51 CDT 2004

On Mon, Sep 20, 2004 at 11:06:33AM +1200, John Rankin wrote:
> Questions:
> 1. What is the preferred method for changing markup behaviour 
> between browse and print/publish?

I'm not exactly sure what the long-term preferred method will be.  
At the moment it's sufficient to make sure that your custom 
markup behaviors (calls to Markup()) are executed before the ones that
come in stdmarkup.php.  The current Markup() function won't
overwrite an existing translation of the same name.

Thus, you can do:

    if ($action=='publish') 

and any later requests to add a "mailto" markup will be ignored by
the Markup function.

Long-term I haven't decided if this is the appropriate behavior for
Markup().  It just seems bizarre that calling Markup() a second or
third time doesn't overwrite the previous definition.  Perhaps I 
need a MarkupDV() function ("markup default value"), which adds a 
markup entry only if one doesn't currently exist.  Either that or
a flag parameter to Markup() or a global variable telling Markup()
what to do (I'm not too fond of either of these).

> 2. Is there any plan to reintroduce a PrintText function? 
> (I have added this to PITS)
> I have made my own which does an echo MarkupToHTML($pagename,$text);
> Or is there another way to do this?

I'm thinking that I will add "markup:..." to the PrintFmt() function
which will do the same thing.  This will also enable wiki markup within
page templates, as in

   <!--markup:A sentence containing ''[[italic page links]]''-->

Because of this, I don't have any plans to reintroduce PrintText, 
although one can always define one locally.

> 3. Is there a preferred method for extending the LinkPage and 
> LinkIMap functions?

Yes, but I'll answer the other sub-questions first...

> Specifically, I want to provide a different rendering for links 
> that refer to the current page (self-references) [...]

This is coming as a built-in feature in the distribution (I'm still working
out the details)

> and a tooltip on links to pages that start with ! or : ... : markup. 
> This can be done, as long as one traps cases where MakeLink has been 
> called with a $fmt set, for example to return the $PageName or $LinkText.

Rather than creating a custom MakeLink for this, I'd suggest recognizing
! and : ... : containing pagenames as custom markup entries.

Now, back to the original question, one can change the default LinkPage
function via $LinkFunctions:

    $LinkFunctions['<:page>'] = 'MyCustomLinkPage';

And for the LinkIMap function, one can create a custom function for
each individual scheme:

    $LinkFunctions['http:'] = 'MyCustomIMap';
    $LinkFunctions['ftp:'] = 'MyCustomIMap';
    $LinkFunctions['news:'] = 'MyCustomIMap';

If you want to do this programmatically to convert all LinkIMaps into
MyCustomIMaps, you can do:

    foreach($LinkFunctions as $k=>$v)
      if ($v=='LinkIMap')  $LinkFunctions[$k]='MyCustomIMap';

> 4. ? and & in link references
> Do I still need to make this a & for sites that have page links 
> of the form http:...?pagename=...

No--you can still use the '?' even on sites that have ?pagename=... links.
I.e., PmWiki knows how to deal with:  

> 5. Has something changed in the way variables are handled?
> I have been very lazy about initialising variables and checking 
> whether they have been set before using them. Now I get a lot of 
> notices about undefined variables. 

For development purposes, I have the PHP error reporting set to E_ALL
so I can catch those cases where I'm using an uninitialized variable.
Normally PHP is set to E_ALL ^ E_NOTICE, which doesn't display the
warnings about using uninitialized variables.  You can restore the
default by doing

    error_reporting(E_ALL ^ E_NOTICE);

and you won't see all the warnings any more.  This will be the default
when PmWiki 2 reaches distribution status.

> They all go away when I add code to set variables to '' or 0 or 
> use an isset($variable) command.

You can also just add a '@' in front of the unset variable, to turn off
the error reporting for that one usage (this is what I do).

> 6. Is there a plan to support inline markups in link text? Should there be?

There's not a plan yet.  Perhaps there should be -- I hadn't really
thought about it much yet.  Inline markups in link text is just a 
pain because of all of the aliasing that takes place.

> How do I invoke processing of selected markups on link text in PmWiki 2?

I don't know if this will work, but perhaps you can change the sequence
of the selected markups so they occur before link processing.
So, for the '' markup, do


which says you want the '' markup to be performed before any link processing.

If this is really important we can see about coming up with a generic
method for handling this.


More information about the pmwiki-users mailing list