[pmwiki-users] New {$$ } and {( )} markups [Was: Can any of the form recipes do this?]

Dominique Faure dominique.faure at gmail.com
Tue Apr 3 10:25:47 CDT 2007


On 4/3/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
[...]
>
> Or, if we really think it's worthwhile to standardize {(...)},
> I propose that we go ahead and identify some standard functions
> that everyone seems to want (time, date, substr, toupper, tolower,
> etc.) and I'll write a base recipe for it that can stand apart
> from either ZAP or Fox.  Then ZAP and Fox can extend that as needed,
> and we'll have much less opportunity for conflict with the {(...)}
> markup in the future.
>

For those interested, I'm in the process (as a background task) of
writing the PageVariableExtension [PVE] substitute recipe. The
targeted syntax I initially planned was to not rely on the variable
syntax anymore, but to provide a sole directive which simply evaluates
its parameter's EXPRESSION like:

  (:eval EXPRESSION:)

The expression would consist in lisp-like bracketed items, where the
most on the left would have been interpreted (when recognized) as a
function call, like in the following mathematical sample:

* ((4+5)*8-9)/20 = (:eval div (sub (mul (add 4 5) 8) 9) 20 :)
* -4 + -5 = (:eval add -4 -5 :)

rendering as:

* ((4+5)*8-9)/20 = 3.15
* -4 + -5 = -9

Variable manipulation would also be possible with:

* Value was (:eval set xx 123:)
* And now (:eval setq xx (add {$xx} 1):) is {$xx}

rendering as:

* Value was 123
* And now is 124

And all the string manipulation functions already provided in PVE
would have equivalent ones available with:

* (:eval substr 'ab cdef':)
* (:eval substr 'ab cdef'  1:)
* (:eval substr 'ab cdef'  1 3:)
* (:eval substr 'ab cdef'  0 4:)
* (:eval substr 'ab cdef'  0 8:)
* (:eval substr 'ab cdef' -1 1:)

rendering as:

* ab cdef
* b cdef
* b c
* ab c
* ab cdef
* f

For now, the implemented functions list is: len, rev, rot13, substr,
tolower, toupper, ucfirst, now, time, ftime, gmftime, fdate, add, sub,
mul, div, rand, quiet, set and setq.

I was then wondering if I could substitute the heavy "(:eval ...:)"
syntax to one of the more friendly "{(...)}" or "{$$...}" ?

Regards,
Dom



More information about the pmwiki-users mailing list