jintervals icon indicating copy to clipboard operation
jintervals copied to clipboard

Support optional prefix text

Open nene opened this issue 16 years ago • 0 comments

Currently we only allow optional suffix text:

jintervals(x, "{Hours? and }{minutes}");

This is usually enough, but it might not always be. For example:

jintervals(x, "Hours: {H}, minutes: {m}");

Especially when we are going to implement {Next}, we will surely need it.

The syntax should be similar to optional suffix, but we can't just do it like that, because:

// so is it "Hoursx" or "xHours"?
jintervals(x, "Hours?Hours");

So maybe add another question-mark at the very beginning:

jintervals(x, "{?Hours: ?H?, }{?minutes: ?m}");

Similarly we should also allow ? at the very end, so that this would be the same:

jintervals(x, "{?Hours: ?H?, ?}{?minutes: ?m?}");

Or maybe we could come up with something more readable:

jintervals(x, "{<Hours: >H<, >}{<minutes: >m}");

Reusing curlies wouldn't be good, as that would make one assume that there is some kind of recursive definition:

jintervals(x, "{{Hours: }H{, }}{{minutes: }m}");

Another example:

jintervals(x, "{Greatest}{< and >Next}");

I also thought about making the optional text disconnected from codes:

jintervals(x, "{Greatest}< and >{Next}");

But this will result in problems, like:

jintervals(x, "{H?}< hours, >{m?}< minutes>");
jintervals(x, "<hours: >{H?}< minutes: >{m?}");

nene avatar Oct 27 '09 21:10 nene