[pmwiki-users] wikistyles.php script change request for consideration

John Rankin john.rankin at affinity.co.nz
Thu Nov 3 23:30:34 CST 2005

Patrick, this is a long email, I'm afraid.

We have been investigating how to process wikistyles through 
the PublishPDF library and came to some tentative conclusions 
which require some non-intrusive changes to wikistyles.php. 
I wanted to run the ideas past you for comment before we go 
much further.

We need to be able to do 2 things:
- apply styles to print dtd tags instead of to html tags
- change attribute names and values to their print 
  equivalents where necessary

What we plan to do for the print output channel is 
- define style variable values as local configuration settings
- let wikistyles.php run as normal
- apply some post-processing rules if necessary

We have identified 3 small changes that would be required to do 
this. They have no effect on the output wikistyles.php produces 
when generating html, but let us see what wikistyles is doing 
and influence its output for print. The first 2 are fairly 
non-controversial; the third we aren't sure what is the best 

1. Insert a comment before every change that wikistyles.php 
   makes, by setting a $WikistyleTag variable to 'wikistyle'
   global $WikistyleTag, $imgTag, $aTag, $spanTag, $blockTags;
   SDV($WikistyleTag, '');
   $wc = ($WikistyleTag=='') ? '' : "<!--$WikistyleTag-->";

   and put $wc before the < in the 5 replace string occurrences

2. Change the hard-coded img, span, a and 
   text to global variables that are initialised via SDV --

   SDV($imgTag, 'img'); SDV($aTag, 'a'); SDV($spanTag, 'span');

   and change the hard-coded tag references accordingly

3. Be able to know exactly what wikistyles.php has changed, so 
   we can post-process it if necessary, but not inadvertently 
   post-process anything else. We have identified 2 ways this 
   could be done:

  - insert a $WikiStyleAttrPrefix before each attribute wikistyles 
    outputs -- $k='$v', $spanattr, and style='color:  {$s['color']}'; 
    for html this would be '' and for print it would be 'wikistyle:' 
    -- we can then match on < ... wikistyle: ... > for post-processing

  - generate <!--$k='$v'--> or <!--$spanattr--> or 
    <!--style='color: {$s['color']}'--> and output this between the 
    $wc and the < in the replace strings; for html this would normally 
    be '' but could be set to the actual values for testing, eg

    $ws = ($wc=='') ? '' : "<!--$k='$v'-->";

Either of these would work. A prefix is more direct, a comment is 
less intrusive. There may be a better way we haven't thought of.

What are our chances of getting scripts/wikistyles.php changed 
along these lines? The changes do not change the normal output, 
but they let us direct wikistyles to do something different 
when we need it to, via parameter settings. It means we don't 
have to distribute and maintain a separate version for the pdf 
library, which is a major benefit, as I'm sure wikistyles will 
continue to change.

Thanks for taking the time to read this. I'll await your
comments with interest. We are focusing quite closely on 
improving wikistyles for print, so should have some results
soon after the direction is set.

Kind regards
John Rankin

More information about the pmwiki-users mailing list