From cbf105b2340879d2381b81148f2cbfe16dfdffbf Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 17 Apr 2014 15:02:56 +0200 Subject: [PATCH] LaTeX-Escaping von HTML: Newlines am Ende entfernen --- SL/Template/LaTeX.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SL/Template/LaTeX.pm b/SL/Template/LaTeX.pm index 6eb331d60..c76b82a62 100644 --- a/SL/Template/LaTeX.pm +++ b/SL/Template/LaTeX.pm @@ -72,8 +72,10 @@ sub _format_html { $content =~ s{ \r+ }{}gx; $content =~ s{ \n+ }{ }gx; $content =~ s{ (?:\ |\s)+ }{ }gx; + $content =~ s{ (?:\ |\s)+$ }{}gx; + $content =~ s{ (?:
)+$ }{}gx; - my @parts = map { + my @parts = grep { $_ } map { if (substr($_, 0, 1) eq '<') { s{ +}{}g; $html_replace{$_} || ''; @@ -83,7 +85,10 @@ sub _format_html { } } split(m{(<.*?>)}x, $content); - return join('', @parts); + $content = join '', @parts; + $content =~ s{ (?: [\n\s] | \\newline )+$ }{}gx; + + return $content; } my %formatters = ( -- 2.20.1