[TxMt] Re: Troubles with regex and language grammar

Allan Odgaard mailinglist at textmate.org
Sun Jan 10 22:58:25 UTC 2016

On 15 Nov 2015, at 13:46, Robert J. Rockefeller wrote:

> Here’s the Markdown Extra in question:
> ![Vagrant Logo](/images/icons/vagrant-logo.png){.image-right 
> .image-33}When developing web sites on the Mac, we have a number of 
> choices for serving the content and design we're working on.
> I’m after the {.image-right .image-33} part and I’ve tried:
> […]
> 		{	name = 'text.html.markdown.classes';
> 			begin = '\)\{';
> 			end = '\}';
> 		},
> […]
> What did I get wrong?

I assume the quoted rule is what you expect to match the classes.

The problem is likely that somewhere else there is another rule matching 
`[«title»](«url»)` so your above rule will not get to match the last 
bracket in the link because it gets eaten by another rule.

You could change the regexp to use a look-behind assertion, for example:

	begin = '\{(?<=\)\{)';

For performance reasons I avoid making the regexp start with the 
look-behind assertion.

More information about the textmate mailing list