[TxMt] Issue with LaTeX syntax highlighting

Charilaos Skiadas skiadas at hanover.edu
Wed Jan 24 21:05:53 UTC 2007


On Jan 23, 2007, at 4:04 AM, Chris Stone wrote:

> While writing a latex document using the array package, I noticed that
> the line
>
>    \newcolumntype{R}{>{$}r<{$}}
>
> confuses TextMate into displaying all following lines as if they  
> were in
> math mode.
>
> Any chance there's an easy fix?
>
There's no particularly easy fix, except perhaps matching >{$} and < 
{$} as special constructs, in which case it would be nice to know all  
other use cases as well (i.e. all things that could reasonably be  
expected to appear in such a >{...} thing).

The problem in a nutshell is as follows: The syntax currently matches  
any pair of braces, with the content in them matched by a  
meta.group.braces scope.
Similarly, it matches pairs of dollar signs, with the content matched  
by math mode.
What this means is that when TM encounters the first dollar sign, it  
searches for its closing dollar sign before it ends the math mode,  
and before even considering closing the braces scope. So it bypasses  
the first closing brace. Then it encounters a second opening brace,  
and decides to start a new group scope, and won't stop until it find  
the closing brace. Then the second dollar sign starts a new math  
mode, and so on.

So I think the best way is to alter it so that >{$} and <{$} are  
matched as a whole. I have now changed the grammar to do so, so if  
you are on svn just svn up and it should work fine.


>    Chris

Haris





More information about the textmate mailing list