[Pmwiki-users] Page preview can now be implemented rather easy

John Rankin john.rankin at affinity.co.nz
Tue Jun 17 17:07:08 CDT 2003


Bernhard, that is very useful.

Using your idea, I created a short script that does the same thing for a =
standard PmWiki install -- an adminitrator just includes preview.php (=
available on request). It introduces a preview action and a HandlePreview =
function.

Where I have got stuck is dealing with [[...]] directives, such as [[=
include: or [[nogroupheader]] in the preview.

Both the PrintText function and $PageEditFmt by default use $Text, so if I =
change $Text to deal with [[...]] stuff, it will also change the form =
contents, which I clearly don't want. I assume there is a way I can tell =
the array that defines the preview screen display to pass a $PreText =
parameter to PrintText, as you have done, and use $Text in the form, but I =
haven't tried it yet.

Incidentally, based on seeing how the HandlePost function works, you may =
need to write:
   $newtext=3Dstr_replace("\r","",stripslashes($HTTP_POST_VARS["text"]));
This might be why your InlineReplacements aren't working.

I also have a minor, but annoying, problem of leading and trailing 'return'=
 characters being stripped off. So my GroupFooter which starts with ---- =
keeps getting turned into 2 em dashes (SmartQuotes finds inline --, =
because the ---- is no longer at the start of a line and doesn't get =
turned into a <hr />).
--=20
John Rankin

On Monday, 16 June 2003 7:28 AM, Bernhard.Weichel at t-online.de wrote:

Hello Patrick,

due to the new features in 0.5.x (in particular PrintText) it is now
possible to implement the highly desired page preview feature. Here is the
code, I am using.

 else if ($myaction=3D=3D"edit" | $myaction=3D=3D"preview")
   {
    global $HTTP_POST_VARS, $Text;
    $newtext=3D$HTTP_POST_VARS["text"];     // don't know how the text =
should be processed
                                          // it seems that fixing inlines =
must be done here
    if ($newtext=3D=3D"") {$newtext=3D$Text;}   // if preview was called =
directly, not via edit

    if ($myaction=3D=3D"preview") {PrintText($pagename, $newtext);}

...






More information about the pmwiki-users mailing list