I'm building up a grammar for the Confluence wiki markup, and I'm having trouble with tags that take a list of parameters.
Tags look like this (all strings are examples only):
{noparams} {oneparam:key=10} {twoparams:keyOne=value|keyTwo=2%} {threeparams:keyA=a value|keyB=another value|keyC=a third value}
So the tag name can stand alone, or if it is followed by ':', it takes a '|'-delimited list of key=value pairs.
When I use the grammar fragment at the end of this message, noparams, oneparam, and twoparams are highlighted as I expect. When there are three or more parameters, the first and last parameters are highlighted as I expect, but the middle ones are highlighted as plain entity.confluence.
I'm sure this is a defect in my match= regular expression, but I'm not seeing it. Could someone enlighten me, please?
— F
{ name = 'entity.confluence'; match = '(?x: { ([-[:alnum:]]+) (:(\w+)=([^|}]+) ( |(\w+)=([^|}]+) )* )? } )'; captures = { 1 = { name = 'keyword.confluence'; }; 3 = { name = 'support.confluence'; }; 4 = { name = 'string.confluence'; }; 6 = { name = 'support.confluence'; }; 7 = { name = 'string.confluence'; }; }; },
I certainly don't have any skills in this area so can't help with the issue, but I do want to say I am happy someone is working on a bundle for confluence wiki :)
Regards Richard
On Sep 5, 2008, at 4:10 PM, Fritz Anderson wrote:
I'm building up a grammar for the Confluence wiki markup, and I'm having trouble with tags that take a list of parameters.
Tags look like this (all strings are examples only):
{noparams} {oneparam:key=10} {twoparams:keyOne=value|keyTwo=2%} {threeparams:keyA=a value|keyB=another value|keyC=a third value}
So the tag name can stand alone, or if it is followed by ':', it takes a '|'-delimited list of key=value pairs.
When I use the grammar fragment at the end of this message, noparams, oneparam, and twoparams are highlighted as I expect. When there are three or more parameters, the first and last parameters are highlighted as I expect, but the middle ones are highlighted as plain entity.confluence.
I'm sure this is a defect in my match= regular expression, but I'm not seeing it. Could someone enlighten me, please?
— F
{ name = 'entity.confluence'; match = '(?x: { ([-[:alnum:]]+) (:(\w+)=([^|}]+) ( |(\w+)=([^|}]+) )* )? } )'; captures = { 1 = { name = 'keyword.confluence'; }; 3 = { name = 'support.confluence'; }; 4 = { name = 'string.confluence'; }; 6 = { name = 'support.confluence'; }; 7 = { name = 'string.confluence'; }; }; },
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 5 Sep 2008, at 23:10, Fritz Anderson wrote:
I'm building up a grammar for the Confluence wiki markup, and I'm having trouble with tags that take a list of parameters.
Tags look like this (all strings are examples only):
{noparams} {oneparam:key=10} {twoparams:keyOne=value|keyTwo=2%} {threeparams:keyA=a value|keyB=another value|keyC=a third value} [...] Could someone enlighten me, please?
You can’t get proper scopes assigned to each item of a variable length list using just one match, so you need to change strategy and use begin/end rules, like in this example:
{ comment = 'match a tag with parameters'; begin = '{\w+:'; end = '}'; patterns = ( { comment = 'match one parameter in the list'; match = '\w+|[^|}]*'; } ); }
The above rule only handles tags with arguments, I would probably do a separate rule for tags without arguments to keep it simple.