[TxMt] pbs with LaTeX labels
Allan Odgaard
throw-away-1 at macromates.com
Sat Jun 2 03:21:42 UTC 2007
On 1. Jun 2007, at 02:34, Édouard Gilbert wrote:
> While I'm at it, is there also a way to escape some commands in the
> same time ?
>
> Typically, when I type
>
> \lastname{Kant}'s life as a title, I'd like it to b converted to
> kant_s_life
>
> But when I type
> \Z is the integer set (\where \Z is a macro to type Z in mathbf)
>
> I'd rather like
> z_is_the_integer_set
>
> Does anyone have an idea of some way to achieve that? I guess the
> first part should be too hard, but I'm far from being an expert in
> regexp.
Not entirely sure of the context -- this is a snippet regexp
transformation?
Presumably something like this will do:
${1:your text} → ${1/\\\w+\{(.*?)\}|\\(.)|(\w+)|(\W+)/(?4:_:$1$2
$3)/g}
Here we match:
a command of the form \command{«value»}
or an escaped character of the form \«char»
or multiple word characters
or multiple non-word characters
If the last branch is taken, we insert an underscore, otherwise we
insert the result of the other captures (we insert all 3, but since
this is an OR, only one will actually have a value).
More information about the textmate
mailing list