[TxMt] MultiMarkdown Bug in Lists...

Fletcher T. Penney fletcher at fletcherpenney.net
Sat Mar 15 23:44:00 UTC 2008


Sorry for the delay - I was traveling...


The problem does occur with my bundle - not sure about with the  
default Markdown bundle.

It appears to be that TextMate is interpreting the '$' as a variable  
indicator, since the output is inserted as a snippet..

This should fix the problem - change the "List - New Sibling" command  
to:

#!/usr/bin/env perl

$line = $ENV{'TM_CURRENT_LINE'};

# If a list item contains '$' it gets treated as a variable by TextMate
# This fixes that problem

$add_to_index = 0;
while ($line =~ s/(?<!\\)\$/\\\$/m) {
	$add_to_index++;
}

$old_line = $line;
$original = $old_line;


if ($ENV{'TM_MARKDOWN_LONG_LIST'} =~ /^y(e|es)?$/i) {
	$newline = "\n\n";
} else {
	$newline = "\n";
}

# Strip Marker
$old_line =~ s/^\s*((\*|\+|\-|\d+\.)\s*)//;

if ($old_line !~ /^\s*$/) {
	# The item was not empty
	
	if ($line =~ s/^(\s*(\*|\+|\-|\d+\.)\s*).*/$1/) {
		# Line was a list item
		$line =~ s{
			(\d+)
		}{
			$1+1;
		}ex;
	} else {
		# Not list item, perhaps a run-on item?
		$line = "";
	}

	$index = $ENV{'TM_LINE_INDEX'};
	$index = $index + $add_to_index;
	$original =~ s/^(.{$index})/$1$newline$line\$0/;

	$original =~ s/`/\\\`/g;
	print $original;#  . "\n" . $line . "\$0";
} else {
	# The item was empty, so end the list
	print "\n";
}


Let me know if this works, and I will release an updated version.   
Thanks!!


Fletcher



On Mar 15, 2008, at 5:40 AM, Allan Odgaard wrote:

> On 12 Mar 2008, at 19:12, Brian H wrote:
>
>> I found an odd bug in the MultiMarkDown list sibling generation:
>>
>> It will strip out any number preceded by a "$" after I hit enter at  
>> the end of the line.
>>
>> EXAMPLE:
>> - Here is a number (1234) and here are some a dollar amounts  
>> ($123), ($123.00), (-$123).
>> - Here is a number (1234) and here are some a dollar amounts (), (. 
>> 00), (-).
>>
>> I think the problem lies in this line:
>>
>> # Strip Marker
>> $old_line =~ s/^\s*((\*|\+|\-|\d+\.)\s*)//;
>>
>> ...but I'm still new to Perl and Regex
>
> It sounds more like lack of snippet-escaping in the output.
>
> But I cannot reproduce this, Are you using the default (out of the  
> box) MultiMarkdown support, or the bundle by Fletcher?
>
>
> ______________________________________________________________________
> 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

And remember: Evil will always prevail, because Good is dumb.
	- Spaceballs

-------------- 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/20080315/cf7e722d/attachment.p7s>


More information about the textmate mailing list