[TxMt] Re: LaTeX Bundle: Wrap in left...right
Alain Matthes
alain.matthes at mac.com
Tue Oct 2 14:47:10 UTC 2007
Le 2 oct. 07 à 15:00, Ruben Debeerst a écrit :
> The command you posted didn't work for me. It didn't copy the
> selected text.
yes with only {text}
>
> Try this one:
> #!/usr/bin/env ruby
> sel = STDIN.read.chomp
> if ( sel =~ /^\\?\{(.+)\\?\}$/)
> print "\\left\\{#{$1}\\right\\}";
> elsif ( sel =~ /^(.)(.+)(.)$/)
> print "\\left#{$1}#{$2}\\right#{$3}";
> end
>
> It will do
> {abc} -> \left\{abc\right\}
> \{abc\} -> \left\{abc\right\}
> and
> [abc] -> \left[abc\right]
> where in the latter case also other characters than [ ] will work.
>
Sorry, I don't send the good one :
#!/usr/bin/env ruby
sel = STDIN.read.chomp
sel.match(/^(.+)(.)$/)
left = $~[1]
right = $~[2]
if right == '}'
left = '\\'+$~[1]
right = '\\}'
end
print "\\left#{left}\\right#{right}"
Regards Alain
More information about the textmate
mailing list