From f487fd80dbc8b15c9a7072abd0c167ac58675bcc Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 4 Feb 2014 14:13:36 +0100 Subject: filter-github-emails: Rewrap more carefully Wrap individual lines instead of formatting whole paragraphs, so that lists such as * first item * second item aren't rewrapped. diff --git a/libexec/filter-github-emails b/libexec/filter-github-emails index 7a05a05..38c2168 100755 --- a/libexec/filter-github-emails +++ b/libexec/filter-github-emails @@ -115,6 +115,18 @@ sub bye { } # +# Wrap overlong lines. +# + +sub rewrap { + my @lines = split(/\n/, shift); + my @wrapped = map { wrap('', '', $_) } @lines; + + debug('Rewrapping text'); + return join("\n", @wrapped); +} + +# # Look up MIME parts. # @@ -154,11 +166,11 @@ sub edit_text_body { debug('Editing text/plain body'); - $body = fill('', '', $body); # While at it, wrap the text. + $body = rewrap($body); # While at it, wrap overlong lines. - $s = '^--- Reply to this email directly or view it on GitHub:'; - $r = "-- \nReply to this email on GitHub:"; - $body =~ s/$s/$r/m; + $s = "\n---\nReply to this email directly or view it on GitHub:"; + $r = "\n-- \nReply to this email on GitHub:"; + $body =~ s/$s/$r/; return $body; } -- cgit v0.10-9-g596f