X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/ea32f94d4ea8a8fd505fbd3eead7ae44dbc22f06..1f8b0477b52069959871280c0899f461f5855b1c:/SL/HTML/Util.pm diff --git a/SL/HTML/Util.pm b/SL/HTML/Util.pm index a54425d83..07031869f 100644 --- a/SL/HTML/Util.pm +++ b/SL/HTML/Util.pm @@ -41,6 +41,31 @@ sub strip { return delete $stripper{text}; } +sub plain_text_to_html { + my ($class_or_text) = @_; + + my $text = !ref($class_or_text) && (($class_or_text // '') eq 'SL::HTML::Util') ? $_[1] : $class_or_text; + + return $text if $text =~ m{^
.*
$}; + + $text =~ s{\r+}{}g; + $text =~ s{^[[:space:]]+|[[:space:]]+$}{}g; + + return '' if $text eq ''; + + my @paragraphs; + + foreach my $paragraph (split m{\n{2,}}, $text) { + no warnings 'once'; + $paragraph = $::locale->quote_special_chars('HTML', $paragraph); + $paragraph =~ s{\n}{' . join('
', @paragraphs) . '
'; +} + 1; __END__ @@ -65,6 +90,12 @@ SL::HTML::Util - Utility functions dealing with HTML Removes all HTML elements and tags from C<$html_content> and returns the remaining plain text. +=item C