aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-11-06 15:45:12 +0000
committerMatthew Somerville <matthew@mysociety.org>2019-11-08 15:27:44 +0000
commiteb68c3fa83ce8796a69429c83adedddba64c7cdc (patch)
tree94ac2c0b5feb86020a3dd974957e8fc4ff8386d2
parent06349f620635fc902499175579d98c83a42debec (diff)
Ignore empty paragraphs in html_para.
And do not generate them needlessly.
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm3
-rw-r--r--perllib/FixMyStreet/Template.pm2
2 files changed, 3 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index ff90132e4..695832832 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -488,7 +488,8 @@ sub inspect : Private {
$c->forward( '/admin/reports/edit_category', [ $problem, 1 ] );
if ($c->stash->{update_text}) {
- $update_text .= "\n\n" . $c->stash->{update_text};
+ $update_text .= "\n\n" if $update_text;
+ $update_text .= $c->stash->{update_text};
}
# The new category might require extra metadata (e.g. pothole size), so
diff --git a/perllib/FixMyStreet/Template.pm b/perllib/FixMyStreet/Template.pm
index 9c565114b..ba4376959 100644
--- a/perllib/FixMyStreet/Template.pm
+++ b/perllib/FixMyStreet/Template.pm
@@ -113,7 +113,7 @@ into <br>s too.
sub html_paragraph : Filter('html_para') {
my $text = shift;
- my @paras = split(/(?:\r?\n){2,}/, $text);
+ my @paras = grep { $_ } split(/(?:\r?\n){2,}/, $text);
s/\r?\n/<br>\n/g for @paras;
$text = "<p>\n" . join("\n</p>\n\n<p>\n", @paras) . "</p>\n";
return $text;