[pmwiki-users] help for recipe needed

Patrick R. Michaud pmichaud at pobox.com
Sun Apr 22 11:26:01 CDT 2007


On Sun, Apr 22, 2007 at 11:19:19AM +0200, Peter K.H. Gragert wrote:
>    Hello
> 
>    Trying to make a nice version of "bridge-hand"-recipe (with $lang for
>    different languages) and polishing up
> 
>    I got this:
> 
>    My script delivers (using _begin)  (not total shown, but enough to
>    describe my questions)
> 
>  http://localhost/pmwiki/pub/pbnbridge/s.gif&nbsp; B 9 3<BR>
> 
>    and it is displayed as
> 
>  <div><img src='http://localhost/pmwiki/pub/pbnbridge/s.gif' alt='' title='' />&nbsp; B 9 3<BR></div>
> 
>    Meaning that pmwiki.php SEES that pictures have to be included, nice.
> 
>    But it is not totally correct , after alt  I  would like to have the first
>    name of the picture (s, h,d or c, respectively) and some title filled in.
>    Who can give me a good hint to get this done?

If you're generating this as part of a markup rule (you mentioned
"_begin", then you can put any <img ... /> tag that you want
directly in the output.  You'll probably want to escape it with
Keep() to prevent PmWiki from attempting to re-interpret the urls
inside of <img src='...' >.


An interesting approach would be to turn the singleton letters
's', 'h', 'd', and 'c' into markups that are turned into images
of the four suites.  Then it becomes very easy to write things like:

    s J 4 2
    h A J 7 6 3 2
    d J
    c 6 3 2

West opens with c K.

and have it display with ' s ', ' h ', ' d ', ' c ', etc.
converted to the appropriate images.  See the example I threw
together at 
   
    http://www.pmwiki.org/wiki/Test/Bridge

The localization code I used for this is:

  SDVA($BridgeSuitImg, array(
    's' => Keep("<img src='$PubDirUrl/bridge/s.gif' alt='s' />"),
    'h' => Keep("<img src='$PubDirUrl/bridge/h.gif' alt='h' />"),
    'd' => Keep("<img src='$PubDirUrl/bridge/d.gif' alt='d' />"),
    'c' => Keep("<img src='$PubDirUrl/bridge/c.gif' alt='c' />")));
  
  Markup('cdhs', 'inline',
    '/(?<=\\s)([cdhs])(?=\\s)/e',
    "\$GLOBALS['BridgeSuitImg']['$1']");

Hope this helps, or at least sparks some interest.  :-)

Pm



More information about the pmwiki-users mailing list