summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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