line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2008, 2009, 2010, 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
|
|
|
|
|
|
|
package HTML::FormatText::Netrik; |
17
|
1
|
|
|
1
|
|
6416
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
18
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
19
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
20
|
1
|
|
|
1
|
|
3
|
use URI::file; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
21
|
1
|
|
|
1
|
|
13
|
use HTML::FormatExternal; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
22
|
|
|
|
|
|
|
our @ISA = ('HTML::FormatExternal'); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
25
|
|
|
|
|
|
|
# use Smart::Comments; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = 23; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
54
|
use constant DEFAULT_LEFTMARGIN => 3; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
30
|
1
|
|
|
1
|
|
3
|
use constant DEFAULT_RIGHTMARGIN => 77; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
36
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# as of Netrik 1.16.1 there's no input charsets, so entitize |
33
|
1
|
|
|
1
|
|
3
|
use constant _WIDE_INPUT_CHARSET => 'entitize'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
152
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Use --dump here as otherwise netrik runs the curses interface on the |
36
|
|
|
|
|
|
|
# initial page given in ~/.netrikrc. If there's no such file then it prints |
37
|
|
|
|
|
|
|
# a little "usage: netrik html-file" but there's nothing interesting in |
38
|
|
|
|
|
|
|
# that. Option '-' to reads stdin which _run_version() makes /dev/null. |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
sub program_full_version { |
41
|
5
|
|
|
5
|
1
|
1180
|
my ($self_or_class) = @_; |
42
|
5
|
|
|
|
|
15
|
return $self_or_class->_run_version (['netrik','--version','--dump','-'], '2>&1'); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
sub program_version { |
45
|
2
|
|
|
2
|
1
|
193
|
my ($self_or_class) = @_; |
46
|
2
|
|
|
|
|
4
|
my $version = $self_or_class->program_full_version; |
47
|
2
|
50
|
|
|
|
5
|
if (! defined $version) { return undef; } |
|
2
|
|
|
|
|
4
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# as of netrik 1.16.1 there doesn't seem to be any option that prints the |
50
|
|
|
|
|
|
|
# version number, it's possible it's not compiled into the binary at all |
51
|
0
|
|
|
|
|
|
return '(not reported)'; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _make_run { |
55
|
0
|
|
|
0
|
|
|
my ($class, $input_filename, $options) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# if (! $options->{'ansi_colour'}) { |
58
|
|
|
|
|
|
|
# push @command, '--bw'; |
59
|
|
|
|
|
|
|
# } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# COLUMNS influences the curses tigetnum("cols") used under --term-width. |
62
|
|
|
|
|
|
|
# Slightly hairy, but it has the right effect. |
63
|
0
|
0
|
|
|
|
|
if (defined $options->{'_width'}) { |
64
|
0
|
|
|
|
|
|
$options->{'ENV'}->{'COLUMNS'} = $options->{'_width'}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# 'netrik_options' not documented ... |
68
|
0
|
0
|
|
|
|
|
return ([ 'netrik', '--dump', '--bw', |
69
|
0
|
|
|
|
|
|
@{$options->{'netrik_options'} || []}, |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# netrik interprets "%" in the input filename as URI style %ff hex |
72
|
|
|
|
|
|
|
# encodings. And it rejects filenames with non-URI chars such as |
73
|
|
|
|
|
|
|
# "-" (except for "-" alone which means stdin). Turn unusual |
74
|
|
|
|
|
|
|
# filenames like "%" or "-" into full file:// using URI::file. |
75
|
|
|
|
|
|
|
URI::file->new_abs($input_filename)->as_string, |
76
|
|
|
|
|
|
|
]); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |