summaryrefslogtreecommitdiff
path: root/localmarkdown2sms
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-24 14:37:25 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-24 14:37:25 +0200
commitbf0ac75d0ed3f72fc69e7cdb22453f8d5a4f0dd8 (patch)
tree63ae89c7fca6030fcc3616e0161d03704eb30cf7 /localmarkdown2sms
parent627f8f410da72b5ca64b4145ccb22b53c97d4810 (diff)
Revert "Tighten tidymsg() to preserve single newlines."
This reverts commit 32e761b2aa1bea94dfbbd80c752e08a32351d155.
Diffstat (limited to 'localmarkdown2sms')
-rwxr-xr-xlocalmarkdown2sms8
1 files changed, 5 insertions, 3 deletions
diff --git a/localmarkdown2sms b/localmarkdown2sms
index 40ba6c6..bee8c74 100755
--- a/localmarkdown2sms
+++ b/localmarkdown2sms
@@ -190,10 +190,12 @@ foreach my $file (read_dir( $path )) {
sub tidymsg {
my $msg = shift @_;
- $msg =~ s/(?<! )\h+?\n(?!\n)//gs; # strip single newline not followed by two spaces
+ $msg =~ s/^\h*$//g; # clean virtually empty lines
+ $msg =~ s/(\S)\h$/$1/g; # strip single trailing space
$msg =~ s/\n\n+/\n\n/g; # strip excess newlines
- $msg =~ s/\h*$//g; # strip all trailing space
- $msg =~ s/^\s*//s; # strip initial leading space
+ $msg =~ s/(\S)\n([^\n])/$1 $2/g; # convert newline to space
+ $msg =~ s/\h*$//g; # strip all trailing spaces
+ $msg =~ s/^\s*(\w*?.*?)\s*$/$1/s; # strip surrounding space
$msg =~ s/’/'/g; #'simplify non-GSM chars
$msg =~ s/…/.../g; # simplify ellipsis
$msg =~ s/\.\.+/.../g; # multiple dots → psudo-ellipsis