summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalmarkdown2sms8
1 files changed, 3 insertions, 5 deletions
diff --git a/localmarkdown2sms b/localmarkdown2sms
index bee8c74..40ba6c6 100755
--- a/localmarkdown2sms
+++ b/localmarkdown2sms
@@ -190,12 +190,10 @@ foreach my $file (read_dir( $path )) {
sub tidymsg {
my $msg = shift @_;
- $msg =~ s/^\h*$//g; # clean virtually empty lines
- $msg =~ s/(\S)\h$/$1/g; # strip single trailing space
+ $msg =~ s/(?<! )\h+?\n(?!\n)//gs; # strip single newline not followed by two spaces
$msg =~ s/\n\n+/\n\n/g; # strip excess newlines
- $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/\h*$//g; # strip all trailing space
+ $msg =~ s/^\s*//s; # strip initial leading space
$msg =~ s/’/'/g; #'simplify non-GSM chars
$msg =~ s/…/.../g; # simplify ellipsis
$msg =~ s/\.\.+/.../g; # multiple dots → psudo-ellipsis