[TxMt] MultiMarkdown Bug in Lists...
Fletcher T. Penney
fletcher at fletcherpenney.net
Sun Mar 16 14:35:04 UTC 2008
OK, I think the following works. Anyone who uses the MMD bundle,
please try it out in various circumstances. My testing indicates that
it works, but I may have missed something.
If I don't hear of any bugs, I'll update the bundle on my web site....
Replace the command for "List - New Sibling" with:
#!/usr/bin/env perl
# New, cleaned up, improved list sibling command
# Thanks to Allan Odgaard and Brian H for finding and
# helping to fix problem with special characters in list items
# 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;
# Now, figure out what to paste back
if ($left =~ /^\s*((\*|\+|\-|\d+\.)\s*)\S+/) {
# We appear to have a list item with content, so create a new sibling
$marker = $1; # What was used as a list item marker?
# If the marker included a counter, increment it
$marker =~ s{
(\d+)
}{
$1+1;
}ex;
print "$left\n$marker$right\$0";
} else {
# Not a list item with content, so strip marker (if any) and add a
newline
$left =~ s/^\s*((\*|\+|\-|\d+\.)\s*)//;
print "$left\n$right\$0";
}
--
Fletcher T. Penney
fletcher at fletcherpenney.net
You're not drunk if you can lie on the floor without holding on.
- Dean Martin
-------------- 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/57ee6d77/attachment.p7s>
More information about the textmate
mailing list