[TxMt] LaTeX diplaymath mode problems

Allan Odgaard throw-away-1 at macromates.com
Mon Nov 7 06:36:02 UTC 2005


On 07/11/2005, at 6.05, Charilaos Skiadas wrote:

> [...] the multi-argument function thingie. I am looking at it  
> though, but I can't quite understand how it works. Can you explain  
> a bit the logic for the end pattern? (  end = '(?=\s*[^\{\[\s])';   )

The begin pattern matches \command and uses look-ahead on [ or {.

Then the sub-rules will match any {…} or […] argument (one rule for  
each).

The end pattern does a look-ahead on something which is NOT [ or  
{ (or space).

So what happens is, the end pattern will cause the matching to stop  
as soon as it can match a non-argument starter character (but using  
look-ahead to not eat it). However, since the sub-rules will match  
any full argument, the end-pattern won't see what's inside {…} or […].

So for example if we have “\foo{bar}fud” then first \foo is matched  
by the begin pattern, the rest of the string is now “{bar}fud”. We  
have 3 candidate rules for this, the two sub patterns and the end- 
rule. One sub-pattern will match “{bar}”, so we're left with “fud”,  
where we again have 3 candidates, this time the end-pattern will  
match it, since it doesn't start with a { or [, and so, we will leave  
the sub-patterns.




More information about the textmate mailing list