[TxMt] Re: LaTeX: || should be verbatim, but not in tabular{|c|c|c}

Daniel Grady d.c.grady at gmail.com
Wed Jan 25 18:47:58 UTC 2012


On 24/01/2012, at 20.54, Dirk Günther wrote:


> I use the LaTeX grammar and I have defined my own shortverb
> command [...] What should I do that |c| in \tabular{...} is not defined as
> verbatim?


As Allan suggested, I think that you need to have a rule in the LaTeX
grammar that will match the column specification part of the tabular
environment. Instead of writing a completely new rule, I tried changing the
relevant existing rule, copied below. The only difference is in the begin
match. I also tried adding your rule for scoping anything between pipes as
verbatim, and this change to the tabular rules seems to do what you want -
anything in the column spec is not scoped as verbatim. Hope that helps!

-Daniel Grady

{ begin = '(?x)
(?:\s*) # Optional whitespace
((\\)begin) # Marker - Function
(\{) # Open Bracket
(array|tabular[xy*]?)
(\}) # Close Bracket
(\s*\{.*\})? # Column specification
(\s*\n)? # Match to end of line absent of content
';
captures = {
1 = { name = 'support.function.be.latex'; };
2 = { name = 'punctuation.definition.function.latex'; };
3 = { name = 'punctuation.definition.arguments.begin.latex'; };
4 = { name = 'variable.parameter.function.latex'; };
5 = { name = 'punctuation.definition.arguments.end.latex'; };
6 = { name = 'variable.columnspec.tabular.latex'; };
};
contentName = 'meta.data.environment.tabular.latex';
end = '(?x)
(?:\s*) # Optional whitespace
((\\)end) # Marker - Function
(\{) # Open Bracket
(\4) # Previous capture from begin
(\}) # Close Bracket
(?:\s*\n)? # Match to end of line absent of content
';
name = 'meta.function.environment.tabular.latex';
patterns = (
{ match = '\\';
name = 'punctuation.definition.table.row.latex';
},
{ begin = '(?:^|(?<=\\\\))(?!\\\\|\s*\\end\{(?:tabular|array))';
end = '(?=\\\\|\s*\\end\{(?:tabular|array))';
name = 'meta.row.environment.tabular.latex';
patterns = (
{ match = '&';
name = 'punctuation.definition.table.cell.latex';
},
{ begin = '(?:^|(?<=&))((?!&|\\\\|$))';
end = '(?=&|\\\\|\s*\\end\{(?:tabular|array))';
name = 'meta.cell.environment.tabular.latex';
patterns = ( { include = '$base'; } );
},
{ include = '$base'; },
);
},
{ include = '$base'; },
);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20120125/272796a2/attachment.html>


More information about the textmate mailing list