[TxMt] MultiMarkdown Bug in Lists...

Fletcher T. Penney fletcher at fletcherpenney.net
Sun Mar 16 12:33:11 UTC 2008


I decided just to rewrite the whole command, to make it easier to fix  
and maintain in the future.  But when I used your substitution, it  
didn't seem to fix anything with the '$' problem:


#!/usr/bin/env perl

# get current line, and break into what is left and right of caret

$line = $ENV{'TM_CURRENT_LINE'};

$index = $ENV{'TM_LINE_INDEX'};
$line =~ /^(.{$index})(.*)$/;
$left = $1;
$right = $2;


# Escape special characters since we will paste as snippet
$left =~ s/(?=[$`\\])/\\/g;
$right =~ s/(?=[$`\\])/\\/g;

$left =~ s/(?<!\\)\$/\\\$/m;


# Print out left and right sides to see how it's working so far  
(routine is not finished yet)
print "$left\n\n$right\n";



If I leave out the "$left =~ s/(?<!\\)\$/\\\$/m;" line (my original  
substitution, it doesn't work.  When I add it back, it does.

What am I doing wrong here?


F-



On Mar 15, 2008, at 10:59 PM, Allan Odgaard wrote:

> On 16 Mar 2008, at 03:35, Allan Odgaard wrote:
>
>> [...]
>> So probably this regexp subst. is more appropriate:
>>
>>   s/(?=[$`\\])/\\/
>
> Actually, that was crafted as a global subst. and not iteratively  
> run on the line, as your code did.
>
> Probably would be best to just count matches (for your  
> $add_to_index) and then run this subst. with /g (and it seems for  
> perl, you need to escape $ even when inside a character class).
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate



-- 
Fletcher T. Penney
fletcher at fletcherpenney.net

For my birthday I got a humidifier and a de-humidifier... I put them
in the same room and let them fight it out.
	- Steven Wright

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2437 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20080316/83924b15/attachment.p7s>


More information about the textmate mailing list