From b7a9e5544f5dd7e6f983625a485ff8fa46af80ae Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 29 Jan 2022 10:20:08 -0500 Subject: display() repects preformat area now --- gmi.pl | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/gmi.pl b/gmi.pl index 8a72f54..3eb79be 100755 --- a/gmi.pl +++ b/gmi.pl @@ -33,8 +33,8 @@ use File::Slurper qw(read_dir); # CPAN # sudo cpanm IO::Socket::SSL URL::XS IO::Pager Text::Wraper Term::ReadKey Path::Naive Text::ParseWords Term::ReadLine Smart::Comments URI::Encode IO::Socket::SSL::Utils File::Slurper my $wrapper = Text::Wrapper->new(columns=>70, body_start=>''); -$ENV{PAGER} = 'most'; -#$ENV{PAGER} = 'less -r'; +#$ENV{PAGER} = 'most'; +$ENV{PAGER} = 'less -R'; my $use_pager = 1; my $pager_text_wrap_auto = 1; my $doc_out = 1; # display doc for human consumption? @@ -685,18 +685,28 @@ sub display { my ($wc) = GetTerminalSize(); $wrapper->columns($wc); } - my $doc; - for (@doc) { - $doc .= $_; - } if ($use_pager) { IO::Pager::open(my $FH) or warn($!); - #print $FH $wrapper->wrap($doc); - print $FH $wrapper->wrap($doc); + for (@doc) { + _pre_block($_); + if ($pre_block) { + print $FH $_; + } + else { + print $FH $wrapper->wrap($_); + } + } } else { - #print($wrapper->wrap($doc)); - print $OUT $wrapper->wrap($doc); + for (@doc) { + _pre_block($_); + if ($pre_block) { + print $OUT $_; + } + else { + print $OUT $wrapper->wrap($_); + } + } } } @@ -791,6 +801,7 @@ sub _is_not_scheme_gemini { sub _pre_block { if (substr($_[0],0,3) eq '```') { toggle($pre_block,1); + return 1; } } -- cgit v1.2.3