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::Zen; |
17
|
1
|
|
|
1
|
|
2650
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
18
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
19
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
20
|
1
|
|
|
1
|
|
6
|
use HTML::FormatExternal; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
21
|
|
|
|
|
|
|
our @ISA = ('HTML::FormatExternal'); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = 23; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
45
|
use constant DEFAULT_LEFTMARGIN => 0; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
26
|
1
|
|
|
1
|
|
3
|
use constant DEFAULT_RIGHTMARGIN => 80; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# no input charset options |
29
|
1
|
|
|
1
|
|
3
|
use constant _WIDE_INPUT_CHARSET => 'entitize'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
165
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub program_full_version { |
32
|
5
|
|
|
5
|
1
|
986
|
my ($self_or_class) = @_; |
33
|
5
|
|
|
|
|
19
|
return $self_or_class->_run_version (['zen', '--version']); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
sub program_version { |
36
|
2
|
|
|
2
|
1
|
237
|
my ($self_or_class) = @_; |
37
|
2
|
|
|
|
|
5
|
my $version = $self_or_class->program_full_version; |
38
|
2
|
50
|
|
|
|
6
|
if (! defined $version) { return undef; } |
|
2
|
|
|
|
|
4
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# eg. "zen version 0.2.3" |
41
|
0
|
0
|
|
|
|
|
$version =~ /^zen version (.*)/i |
42
|
|
|
|
|
|
|
or $version =~ /^(.*)/; # whole first line if format not recognised |
43
|
0
|
|
|
|
|
|
return $1 . substr($version,0,0); # retain taintedness |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _make_run { |
47
|
0
|
|
|
0
|
|
|
my ($class, $input_filename, $options) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Is it worth enforcing/checking this ? |
50
|
|
|
|
|
|
|
# Could use Encode.pm to convert the output without too much trouble. |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
# if (my $input_charset = $options->{'input_charset'}) { |
53
|
|
|
|
|
|
|
# $input_charset =~ /^latin-?1$|^iso-?8859-1$/i |
54
|
|
|
|
|
|
|
# or croak "Zen only accepts latin-1 input"; |
55
|
|
|
|
|
|
|
# } |
56
|
|
|
|
|
|
|
# if (my $output_charset = $options->{'output_charset'}) { |
57
|
|
|
|
|
|
|
# $output_charset =~ /^latin-?1$|^iso-?8859-1$/i |
58
|
|
|
|
|
|
|
# or croak "Zen only produces latin-1 output"; |
59
|
|
|
|
|
|
|
# } |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# 'zen_options' not documented ... |
62
|
0
|
0
|
|
|
|
|
return ([ 'zen', '-i', 'dump', |
63
|
0
|
|
|
|
|
|
@{$options->{'zen_options'} || []}, |
64
|
|
|
|
|
|
|
'--', # end of options |
65
|
|
|
|
|
|
|
$input_filename, |
66
|
|
|
|
|
|
|
]); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
__END__ |