From fb5c189f1178071e0d5b6e2dcc6bdd1adfd7b976 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Sun, 13 Nov 2022 03:53:58 +0100 Subject: [PATCH] Fixing broken words preview. --- lib/BurguillosInfo/Posts.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/BurguillosInfo/Posts.pm b/lib/BurguillosInfo/Posts.pm index 256b337..867daff 100644 --- a/lib/BurguillosInfo/Posts.pm +++ b/lib/BurguillosInfo/Posts.pm @@ -79,18 +79,25 @@ sub PostPreviewOg { my @content_divided_in_lines = split /\n/, $content; my @new_content; - my $n_chars_per_line = 60; + my $n_chars_per_line = 70; for my $line (@content_divided_in_lines) { if ( length($line) <= $n_chars_per_line ) { push @new_content, $line; next; } + my $last_word = ''; while ( $line =~ /(.{1,${n_chars_per_line}})/g ) { - my $new_line = $1; + my $new_line = $last_word.$1; + $new_line =~ s/(\S*)$//; + $last_word = $1; push @new_content, $new_line; } + if ($last_word) { + $new_content[$#new_content] .= $last_word; + } } + my $svg = $self->_GenerateSVGPostPreview( $title, \@new_content ); my ($stdout) = capture { open my $fh, '|-', qw{convert /dev/stdin png:fd:1};