[TxMt] Language Grammar: content depending names of captures

Hans-Jörg Bibiko bibiko at eva.mpg.de
Fri Nov 30 09:31:12 UTC 2007


Hi,

I only have a tiny question and I didn't find anything in the archive.

E.g. I have that grammar snippet:

	name = 'meta.tag.any.html';
	begin = '(<)([a-zA-Z0-9:]+)(?=[^>]*></\2>)';
	end = '(>(<)/)(\2)(>)';
	beginCaptures = {
		1 = { name = 'punctuation.definition.tag.html'; };
		2 = { name = 'entity.name.tag.html'; };

Is it possible to name the beginCaptures 1 and 2 according to values  
found in the regexp groups like for group 2

	name = 'meta.tag.any.html';
	begin = '(<)([a-zA-Z0-9:]+)(?=[^>]*></\2>)';
	end = '(>(<)/)(\2)(>)';
	beginCaptures = {
		1 = { name = 'punctuation.definition.tag.html'; };
		2 = { name = 'entity.name.tag.html.$2'; };

or

		2 = { name = 'entity.name.tag.html.$self'; };

$2 or $self referring to the actual content of the found regexp group  
2 to get:

<meta.tag.any.html>
<punctuation.definition.tag.html><</punctuation.definition.tag.html>
<entity.name.tag.html.title>title</entity.name.tag.html.title>
<punctuation.definition.tag.html>></punctuation.definition.tag.html>

Thanks,

--Hans



More information about the textmate mailing list