| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2008, 2009, 2010, 2012, 2013, 2015 Kevin Ryde |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# HTML-FormatExternal is free software; you can redistribute it and/or |
|
4
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License as published |
|
5
|
|
|
|
|
|
|
# by the Free Software Foundation; either version 3, or (at your option) any |
|
6
|
|
|
|
|
|
|
# later version. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# HTML-FormatExternal is distributed in the hope that it will be useful, but |
|
9
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
10
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
11
|
|
|
|
|
|
|
# for more details. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
|
14
|
|
|
|
|
|
|
# with HTML-FormatExternal. If not, see . |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# elinks.conf(5) describes the various config options |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
# Maybe: |
|
20
|
|
|
|
|
|
|
# --dump-charset UTF-8 ?? |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package HTML::FormatText::Elinks; |
|
25
|
2
|
|
|
2
|
|
2184
|
use 5.006; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
59
|
|
|
26
|
2
|
|
|
2
|
|
7
|
use strict; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
45
|
|
|
27
|
2
|
|
|
2
|
|
17
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
51
|
|
|
28
|
2
|
|
|
2
|
|
723
|
use URI::file; |
|
|
2
|
|
|
|
|
14894
|
|
|
|
2
|
|
|
|
|
40
|
|
|
29
|
2
|
|
|
2
|
|
452
|
use HTML::FormatExternal; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
21
|
|
|
30
|
|
|
|
|
|
|
our @ISA = ('HTML::FormatExternal'); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = 23; |
|
33
|
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
|
90
|
use constant DEFAULT_LEFTMARGIN => 3; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
110
|
|
|
35
|
2
|
|
|
2
|
|
6
|
use constant DEFAULT_RIGHTMARGIN => 77; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
591
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub program_full_version { |
|
38
|
5
|
|
|
5
|
1
|
1368
|
my ($self_or_class) = @_; |
|
39
|
5
|
|
|
|
|
21
|
return $self_or_class->_run_version (['elinks', '-version']); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
sub program_version { |
|
42
|
2
|
|
|
2
|
1
|
327
|
my ($self_or_class) = @_; |
|
43
|
2
|
|
|
|
|
6
|
my $version = $self_or_class->program_full_version; |
|
44
|
2
|
50
|
|
|
|
9
|
if (! defined $version) { return undef; } |
|
|
2
|
|
|
|
|
6
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# eg. "ELinks 0.12pre2\n |
|
47
|
|
|
|
|
|
|
# Built on Oct 2 2008 18:34:16" |
|
48
|
|
|
|
|
|
|
# |
|
49
|
0
|
0
|
|
|
|
0
|
$version =~ /^ELinks (.*)/i |
|
50
|
|
|
|
|
|
|
or $version =~ /^(.*)/; # whole first line if format not recognised |
|
51
|
0
|
|
|
|
|
0
|
return $1 . substr($version,0,0); # retain taintedness |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _make_run { |
|
55
|
0
|
|
|
0
|
|
0
|
my ($class, $input_filename, $options) = @_; |
|
56
|
0
|
|
|
|
|
0
|
my @command = ('elinks', '-dump', '-force-html'); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# if ($options->{'ansi_colour'}) { |
|
59
|
|
|
|
|
|
|
# push @command, '-eval', 'set document.dump.color_mode=1'; |
|
60
|
|
|
|
|
|
|
# } |
|
61
|
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
0
|
if (defined $options->{'_width'}) { |
|
63
|
0
|
|
|
|
|
0
|
push @command, |
|
64
|
|
|
|
|
|
|
'-dump-width', $options->{'_width'}, |
|
65
|
|
|
|
|
|
|
'-eval', 'set document.browse.margin_width=0'; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
0
|
if (my $input_charset = $options->{'input_charset'}) { |
|
69
|
0
|
|
|
|
|
0
|
$input_charset = _elinks_mung_charset ($input_charset); |
|
70
|
0
|
|
|
|
|
0
|
push @command, |
|
71
|
|
|
|
|
|
|
'-eval', ('set document.codepage.assume=' |
|
72
|
|
|
|
|
|
|
. _quote_config_stringarg($input_charset)), |
|
73
|
|
|
|
|
|
|
'-eval', 'set document.codepage.force_assumed=1'; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
0
|
|
|
|
0
|
if (my $output_charset = $options->{'output_charset'}) { |
|
77
|
0
|
|
|
|
|
0
|
push @command, '-dump-charset', _elinks_mung_charset ($output_charset); |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# 'elinks_options' not documented ... |
|
81
|
0
|
0
|
|
|
|
0
|
push @command, @{$options->{'elinks_options'} || []}; |
|
|
0
|
|
|
|
|
0
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# elinks takes any "-foo" to be an option (except a bare "-") and |
|
84
|
|
|
|
|
|
|
# there's no apparent "--" to end options (in its version 0.12pre5). |
|
85
|
|
|
|
|
|
|
# Filenames starting "http:" are rejected. |
|
86
|
|
|
|
|
|
|
# Turn into file:// using URI::file to ensure literal filename. |
|
87
|
|
|
|
|
|
|
# |
|
88
|
0
|
|
|
|
|
0
|
push @command, URI::file->new_abs($input_filename)->as_string; |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
return (\@command); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# elinks (version 0.12pre2 at least) is picky about charset names in a |
|
94
|
|
|
|
|
|
|
# similar fashion to the main "links" program (see Links.pm). Turn |
|
95
|
|
|
|
|
|
|
# "latin-1" into "latin1" here for convenience. |
|
96
|
|
|
|
|
|
|
# |
|
97
|
|
|
|
|
|
|
sub _elinks_mung_charset { |
|
98
|
0
|
|
|
0
|
|
0
|
my ($charset) = @_; |
|
99
|
0
|
|
|
|
|
0
|
$charset =~ s/^(latin)-([0-9]+)$/$1$2/i; |
|
100
|
0
|
|
|
|
|
0
|
return $charset; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# Return $str with quotes around it, and backslashed within it, suitable for |
|
104
|
|
|
|
|
|
|
# use in an elinks config file or -eval of a config file line. |
|
105
|
|
|
|
|
|
|
sub _quote_config_stringarg { |
|
106
|
3
|
|
|
3
|
|
1012
|
my ($str) = @_; |
|
107
|
3
|
|
|
|
|
5
|
$str =~ s/'/\\'/g; # ' -> \' |
|
108
|
3
|
|
|
|
|
10
|
return "'$str'"; # '$str' surrounding quotes |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
__END__ |