summaryrefslogtreecommitdiff
path: root/localmarkdown2sms
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-23 17:36:20 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-23 17:36:20 +0200
commit32e761b2aa1bea94dfbbd80c752e08a32351d155 (patch)
tree69aba69d79efd371fea9aac3e74e51d6e605268c /localmarkdown2sms
parent12fe2782a1c7aa060dd03a1b786d944136ae5023 (diff)
Tighten tidymsg() to preserve single newlines.
Diffstat (limited to 'localmarkdown2sms')
-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