Feature request: merge function!

Mark Waddingham mark at livecode.com
Fri Jan 18 07:52:37 EST 2019


On 2019-01-18 09:01, David Bovill via use-livecode wrote:
> I would love to be able to change the characters that merge uses -
> especially from “[[..]]” to “{{...}}”.
> 
> Quite a lot of templating uses curly brackets - and I especially want 
> to
> use it for wiki style templates which can’t use square brackets as they 
> are
> used for internal links.
> 
> Not sure of the most elegant syntax, but we could add some Paramus 
> without
> breaking anything.

The current string scanning which the merge function relies on 5 
codeunits (not characters!):

   - expression start ('[')
   - expression finish (']')
   - script start ('<')
   - script finish ('>')
   - script marker ('?')

With constraints:
   - expression start != expression end
   - script start != script finish != script marker
   - expression start != script start
   - expression finish != script finish

So the easiest / simplest least-likelihood-of-breaking-anything approach 
would be to add an optional parameterization to the merge function 
consisting of a string between 2 and 5 codeunits:

   - string of 2 codeunits: change expression start / finish, leave 
script markers the same
   - string of 3 codeunits: change script start / finish / marker, leave 
expression markers the same
   - string of 4 codeunits: change expression start / finish and script 
start / finish, leave script marker the same
   - string of 5 codeunits: change all characters

In all cases it would need to be an error if the above constraints don't 
hold.

For example...

To get David's wiki-safe option you'd just parameterize by "{}".

Similarly, merge is not completely XML safe - <?xml version="1.0"> is a 
valid XML directive *and* a value LCS command call (xml version = "1.0") 
- so to make that better you could parameterize by "<>|" (<| not being a 
valid sequence except in CDATA, which you can elect not to use by entity 
escaping chars instead).

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list