summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjake <jake@jakes-mail.top>2022-01-29 10:20:08 -0500
committerjake <jake@jakes-mail.top>2022-01-29 10:20:08 -0500
commitb7a9e5544f5dd7e6f983625a485ff8fa46af80ae (patch)
treee1ffc11ac23c922a3bafdcdc4903c3540411bfec
parente52c14ee24be22451f016bd449de1caa2232e94c (diff)
display() repects preformat area now
-rwxr-xr-xgmi.pl31
1 files 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;
}
}