[pmwiki-users] relative position style

Mark Lee mark.lee.phd at gmail.com
Wed May 8 19:26:07 CDT 2013


Thanks Peter. So helpful.
I have been reading about regular expressions. I am wondering why we need
"\\" in the pattern  '/\\(:plant\\s*(.*?):\\)/e'? I know that "\(" means
the "(" character, but what does "\\(" mean? The extra "\" is also used
before "\s" and "\)". Is that part of pmwiki?
-Mark


On Wed, May 8, 2013 at 7:47 AM, Peter Bowers <pbowers at pobox.com> wrote:

> On Wed, May 8, 2013 at 4:23 PM, Mark Lee <mark.lee.phd at gmail.com> wrote:
>
>> The X and Y position of the plant on the map is contained on the page.
>> Lets say a tree is located at map coordinates <100,250>. I was thinking to
>> use the markup (:xposition 100:) (:yposition 250). I could then use this
>> information in what ever way is supported by pmwiki markup via
>> {$:xposition} and {$:yposition}.
>> 5. In html, I am able to place a marker using styles. For example, if I
>> want a marker "1" at position <132,165> I use <plant
>> style="position:relative; left:132px; top:165px">2</plant></p>. Is this
>> possible in pmwiki?
>>
>
> Just set up your (:plant ...:) custom markup so that it produces this
> HTML...
>
> Something like this:
>
> (:plant 2 x=100 y=250:)
>
> See http://www.pmwiki.org/wiki/PmWiki/CustomMarkup or
> http://www.pmwiki.org/wiki/PmWiki/CustomMarkupAlt to see how to create
> your own markup.  You will also want to take a look at
> http://www.pmwiki.org/wiki/Cookbook/ParseArgs to handle the arguments
> nicely.
>
> To get a quick idea of what it'll look like, here's a very slightly tested
> chunk of code that may be somewhat close to what you want:
>
> ===(snip)===
> Markup('plant', 'directives',
>   '/\\(:plant\\s*(.*?):\\)/e',
>   'Plant($pagename, "$1")');
>
> function Plant($pagename, $args)
> {
>
>    $opts = ParseArgs($args);
>    echo "opts=".print_r($opts,true)."<br />\n";
>
>    $x = (@$opts['x'] ? $opts['x'] : 0);
>    $y = (@$opts['y'] ? $opts['y'] : 0);
>    $num = (@$opts['num'] ? $opts['num'] : 'Unnumbered');
>
>    $out = "<plant style=\"position: relative; left: ${x}px; top:
> ${y}px\">$num</plant>";
>
>    return Keep($out);
> }
> ===(snip)===
>
> That should get the basic idea -- you can get more elegant using
> positional parameters with ParseArgs or something, but this should be a
> good start.
>
> -Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20130508/377f460e/attachment.html>


More information about the pmwiki-users mailing list