File Coverage

blib/lib/WWW/Noss/Lynx.pm
Criterion Covered Total %
statement 11 20 55.0
branch 0 4 0.0
condition 0 2 0.0
subroutine 4 5 80.0
pod 1 1 100.0
total 16 32 50.0


line stmt bran cond sub pod time code
1             package WWW::Noss::Lynx;
2 2     2   111485 use 5.016;
  2         9  
3 2     2   14 use strict;
  2         13  
  2         77  
4 2     2   14 use warnings;
  2         4  
  2         185  
5             our $VERSION = '2.02';
6              
7 2     2   15 use Exporter qw(import);
  2         6  
  2         719  
8             our @EXPORT_OK = qw(lynx_dump);
9              
10             my @DUMP_OPTS = qw(
11             -dump
12             -force_html
13             -nolist
14             -display_charset=utf8
15             );
16              
17             sub lynx_dump {
18              
19 0     0 1   my ($file, %param) = @_;
20 0   0       my $width = $param{ width } // 80;
21              
22 0           my $cmd =
23             sprintf "lynx @DUMP_OPTS %s '%s'",
24             "-width '$width'",
25             $file;
26              
27 0           my $dump = qx/$cmd/;
28              
29 0 0         if ($? == -1) {
30 0           die "Failed to execute lynx, is it installed?\n";
31             }
32              
33 0 0         if ($? >> 8 != 0) {
34 0           die "Failed to dump $file with lynx\n";
35             }
36              
37 0           return $dump;
38              
39             }
40              
41             =head1 NAME
42              
43             WWW::Noss::Lynx - lynx interface
44              
45             =head1 USAGE
46              
47             use WWW::Noss::Lynx qw(lynx_dump);
48              
49             my $dump = lynx_dump($html_file);
50              
51             =head1 DESCRIPTION
52              
53             B is a module that provides an interface to the L
54             command for formatting HTML. This is a private module, please consult the
55             L manual for user documentation.
56              
57             =head1 SUBROUTINES
58              
59             Subroutines are not exported automatically.
60              
61             =over 4
62              
63             =item $dump = lynx_dump($html, [ %param ])
64              
65             Dumps the HTML file C<$html> using L's C<-dump> option. Returns the
66             formatted text. Dies on failure.
67              
68             C<%param> is an optional hash argument for providing additional parameters to
69             C. The follow are a list of valid fields:
70              
71             =over 4
72              
73             =item width
74              
75             Line width to use for formatted text dump. Defaults to C<80>.
76              
77             =back
78              
79             =back
80              
81             =head1 AUTHOR
82              
83             Written by Samuel Young, Esamyoung12788@gmail.comE.
84              
85             This project's source can be found on its
86             L. Comments and pull
87             requests are welcome!
88              
89             =head1 COPYRIGHT
90              
91             Copyright (C) 2025-2026 Samuel Young
92              
93             This program is free software: you can redistribute it and/or modify
94             it under the terms of the GNU General Public License as published by
95             the Free Software Foundation, either version 3 of the License, or
96             (at your option) any later version.
97              
98             =head1 SEE ALSO
99              
100             L, L
101              
102             =cut
103              
104             1;
105              
106             # vim: expandtab shiftwidth=4