diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-02-18 22:04:28 (GMT) |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2014-02-18 22:04:28 (GMT) |
commit | 309e885a592a8d2d21b2b7ae5c1a28c5c89ce1fc (patch) | |
tree | fe042eb5a0757f5516a928cbb5322e297ebaec3b | |
parent | dd86a25716364718cbac4b9ea4ee19415408eb77 (diff) | |
download | site-309e885a592a8d2d21b2b7ae5c1a28c5c89ce1fc.tar.gz |
filter-github-emails: Rewrap blockquotes properly
When wrapping a line that begins with a ">", let all resulting lines
begin with a ">". (Properly handle nested blockquotes, too.)
-rwxr-xr-x | libexec/filter-github-emails | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libexec/filter-github-emails b/libexec/filter-github-emails index 6f1f3a6..326495d 100755 --- a/libexec/filter-github-emails +++ b/libexec/filter-github-emails | |||
@@ -119,7 +119,19 @@ sub bye { | |||
119 | # | 119 | # |
120 | 120 | ||
121 | sub rewrap { | 121 | sub rewrap { |
122 | my $wrap = sub { /^(?: {4}|\t)/ ? $_ : wrap('', '', $_) }; | 122 | my $wrap = sub { |
123 | my $line = shift; | ||
124 | my $indent; | ||
125 | |||
126 | if ($line =~ /^(?: {4}|\t)/) { | ||
127 | return $line; | ||
128 | } elsif (/^([> ]+)/) { | ||
129 | $indent = $1; | ||
130 | } else { | ||
131 | $indent = ''; | ||
132 | } | ||
133 | return wrap('', $indent, $line); | ||
134 | }; | ||
123 | my @lines = split(/\n/, shift); | 135 | my @lines = split(/\n/, shift); |
124 | my @wrapped = map { $wrap->($_) } @lines; | 136 | my @wrapped = map { $wrap->($_) } @lines; |
125 | 137 | ||