[pmwiki-users] Math/Php markup... ZAPbeta 2007-03 tweaks...
The Editor
editor at fast.st
Sun Mar 18 11:47:13 CDT 2007
On 3/18/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Sun, Mar 18, 2007 at 12:26:10AM -0400, The Editor wrote:
> > {#c substr|How are you today, 5,3} and get something like "you" back.
>
> Nitpick: I would hope that this would return "are", not "you". :-) :-)
>
> Some other thoughts/reactions...
>
> I think I would caution against this particular markup, because it
> seems likely to run into some problems. First, depending on how
> you're parsing the string, it would seem that one would run into
> difficulty performing operations on strings containing curly
> braces or commas. Instead of the single curly brace closer,
> I'd suggest a 2-character closing sequence, such as "#}".
Commas are no problem in this case. I could try the closing character
sequence--though it would break a lot of stuff in my snippets...
> Beyond that, I don't quite see the purpose of the "#c" at
> the beginning of the markup. It seems to me that one could
> just as easily do the clearer:
>
> {#substr How are you today, 5, 3 #}
> {#strftime %Y-%d-%m #}
> {#date#}
> {#time#}
> {#crypt foo#}
> {#math (2+3)*5/2.5 #}
>
> But then this makes me wonder if we really need a new
> syntax marker for this, and if we couldn't just use
> the (:...:) syntax we already have for selected functions:
>
> (:substr "How are you today" 5 3:)
> (:strftime %Y-%d-%m:)
> (:date:)
> (:time:)
> (:crypt foo:)
> (:math 2+3*5/2.5 :)
As ZAP escapes :) this would mean these could not be stored in text
vars. Another important use...
> I do admit there seems to be something subtly different
> between these functions and what we normally think of as
> "directives". But there's also something to be said with
> avoiding the question of "am I supposed to use (:...:)
> or {#...#} here?"
>
> It's also the case that we've tended to use curlies
> to indicate things that are "inline substitutions" --
> page variables come to mind, as well as the various
> math markups {$...$}.
>
> I'm also not sure that someone might want to use {#...#}
> some day for another purpose, especially since we already
> have things like {-...-}, {+...+}, etc. The '#' character
> doesn't read "function" to me. Perhaps a better syntax
> would be something like {(...)}, as in:
>
> {(substr "How are you today" 5 3)}
> {(strftime %Y-%d-%m)}
> {(date)}
> {(time)}
> {(crypt foo)}
> {(math 2+3*5/2.5 )}
>
> Just some thoughts...
>
> Pm
Thanks Pm, here's the reason behind this syntax. I actually have
several markups in ZAPmarkups.php that introduce what I call ZAP
variables. They process just after Page and Text vars and before the
if's so you can kind of nest them (a page in a text in a zap variable)
which is quite useful for some advanced applications. I chose the #
symbol for lack of something better.
Each of the different markups functions are trigger by a different key
letter so:
{#t parameter} deals with time
{#g parameter} deals with groups (count and threads)
{#c parameter} deals with math/php commands
{#r parameter} random number plus $captcha
This allows me to keep a consistent syntax gives me room to expand.
It's also simple and easy to use. And for me at least, sticks in my
head pretty easily.
On the other hand, I do like
{(math 2+3*5/2.5 )} quite well, and would be willing to stake out some
territory here if that's acceptable with you. I could even make it
one function perhaps, with a switch/cases: something like:
{(timeset )} For my time functions
{(count )} Or groupcount
{(thread )}
{(captcha )}
{(math )}
{(substr, etc )} In approved SDV list
I like it. It has the suggestion of a variable and a function. Which
is what it really is.
Any other thoughts before I make the change? You have a knack for
markup syntax Pm!
Cheers,
Dan
More information about the pmwiki-users
mailing list