[TxMt] Language gramar and end match

Pedro Melo melo at simplicidade.org
Fri Nov 5 16:19:36 UTC 2010


Hi,

I have a small embedded mini-language that allows me to include HTML
and CSS files inline inside the code.

The layout is something like this:

------ 8< -----
@@ filename.html
<div>....</div>

@@ styles.css
... css stuff ...

@@ other.html
... more html...

------ 8< -----

I'm using something like this:

		{	name = 'embedded.html';
			begin = '^(@@)\s+(.+[.]html?)\s*$';
			end = '^@@';
			captures = {
				1 = { name = 'embedded.marker'; };
				2 = { name = 'embedded.filename'; };
			};
			patterns = ( { include = 'text.html'; } );
		},
		{	name = 'embedded.css';
			begin = '^(@@)\s+(.+[.]css)\s*$';
			end = '^@@';
			captures = {
				1 = { name = 'embedded.marker'; };
				2 = { name = 'embedded.filename'; };
			};
			patterns = ( { include = 'text.css'; } );
		},

But the problem is that the "end" rule captures the @@ pair to it
cannot be matched by the next block "begin".

If I add an extra @@ just before the second file, it all works fine.

Is there any trick to get around this?

Thanks,
-- 
Pedro Melo
http://www.simplicidade.org/
xmpp:melo at simplicidade.org
mailto:melo at simplicidade.org


More information about the textmate mailing list