[pmwiki-users] How to create markup macros?
Harry Forsdick
harry at forsdick.com
Wed Feb 7 07:24:53 CST 2007
Dom,
Thank you. That was very helpful and got me on my way to making this
work...
-- Harry
On 2/7/07, Dominique Faure <dominique.faure at gmail.com> wrote:
>
> On 2/7/07, Harry Forsdick <harry at forsdick.com> wrote:
> > I have mastered some parts of extending pmWiki markup, but there is one
> > simple case that I can't seem to get to work.
> >
> > In a travelog that has navigation between pages, I have been laboriously
> > copying the same code at the top and bottom of each pakge and then
> modifying
> > it so that there is a previous day and next day link. The wiki code is
> > something like:
> >
> > ||[[Main.MonFeb05|<- Monday, February 5]] || [[
> Main.WedFeb07|Wednesday,
> > February 7 ->]]||
> >
> > I have gotten tired of this copying and so I decided to create what I
> think
> > of as a macro to generate the pmWiki language code from a short
> directive:
> >
> > (:navprevnext Feb6:)
> >
> > the code that I have added to my config.php file is:
> >
> > ## NAVPREVNEXT
> > Markup('navprevnext', 'fulltext', '/\\(:navprevnext +(.*?):\\)/e',
> > "GenerateNavPrevNextCode('$1')");
> > function GenerateNavPrevNextCode($DateStr)
> > {
> > $date = strtotime($DateStr);
> > $prev = $date - 86400;
> > $next = $date + 86400;
> >
> > $result = "||[[Main." . date("DMd",$prev) . "|<- " . date("l, F j",
> $prev)
> > . "]] || [[Main." . date("DMd",$next) . "|" . date("l, F j", $next) . "
> > ->]]||";
> >
> > return Keep($result);
> > }
> >
> > The problem is that the pmWiki markup appears, not the interpretation of
> the
> > markup.
> >
>
> The Keep() function prevent your computed result to be interpreted as
> further markup. You should have a try without it:
>
> ...
> return $result;
> }
>
> Dom
>
--
Harry Forsdick
781.861.6149 (home) 781.799.6002 (cell)
http://www.forsdick.com
http://forsdick.blogspot.com
http://www.lexdig.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20070207/8cd538b6/attachment.html
More information about the pmwiki-users
mailing list