| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This file is part of Pod-Markdown |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2011 by Randy Stauner. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
11
|
|
|
11
|
|
56174
|
use 5.008; |
|
|
11
|
|
|
|
|
32
|
|
|
11
|
11
|
|
|
11
|
|
51
|
use strict; |
|
|
11
|
|
|
|
|
14
|
|
|
|
11
|
|
|
|
|
255
|
|
|
12
|
11
|
|
|
11
|
|
95
|
use warnings; |
|
|
11
|
|
|
|
|
16
|
|
|
|
11
|
|
|
|
|
544
|
|
|
13
|
|
|
|
|
|
|
# PODNAME: pod2markdown |
|
14
|
|
|
|
|
|
|
# ABSTRACT: Convert POD text to Markdown |
|
15
|
|
|
|
|
|
|
|
|
16
|
11
|
|
|
11
|
|
6252
|
use Pod::Markdown; |
|
|
11
|
|
|
|
|
44
|
|
|
|
11
|
|
|
|
|
478
|
|
|
17
|
11
|
|
|
11
|
|
8295
|
use Getopt::Long; |
|
|
11
|
|
|
|
|
156519
|
|
|
|
11
|
|
|
|
|
60
|
|
|
18
|
11
|
|
|
11
|
|
8487
|
use Pod::Usage; |
|
|
11
|
|
|
|
|
126575
|
|
|
|
11
|
|
|
|
|
19291
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
11
|
|
|
|
|
4228110
|
my %opts = ( |
|
21
|
|
|
|
|
|
|
# Since we're writing to a file the module needs to know that it has to do |
|
22
|
|
|
|
|
|
|
# some kind of encoding. Default to UTF-8. |
|
23
|
|
|
|
|
|
|
output_encoding => 'UTF-8', |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
11
|
50
|
|
|
|
114
|
GetOptions(\%opts, qw( |
|
27
|
|
|
|
|
|
|
help|h |
|
28
|
|
|
|
|
|
|
html_encode_chars|html-encode-chars=s |
|
29
|
|
|
|
|
|
|
local_module_url_prefix|local-module-url-prefix=s |
|
30
|
|
|
|
|
|
|
match_encoding|match-encoding|m |
|
31
|
|
|
|
|
|
|
man_url_prefix|man-url-prefix=s |
|
32
|
|
|
|
|
|
|
perldoc_url_prefix|perldoc-url-prefix=s |
|
33
|
|
|
|
|
|
|
output_encoding|output-encoding|e=s |
|
34
|
|
|
|
|
|
|
utf8|utf-8|u |
|
35
|
|
|
|
|
|
|
)) or pod2usage(2); |
|
36
|
11
|
50
|
|
|
|
15455
|
pod2usage(1) if $opts{help}; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# TODO: Test PERL_UNICODE and/or layers on the handle? |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Expand alias (-u is an alias for -e UTF-8). |
|
41
|
11
|
50
|
|
|
|
47
|
$opts{output_encoding} = 'UTF-8' if delete $opts{utf8}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# TODO: Pod::Simple::parse_from_file(@ARGV[0,1]); |
|
44
|
|
|
|
|
|
|
|
|
45
|
11
|
|
|
|
|
93
|
my $in_fh = get_handle(shift(@ARGV), '<', \*STDIN); |
|
46
|
11
|
|
|
|
|
50
|
my $out_fh = get_handle(shift(@ARGV), '>', \*STDOUT); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Undo any PERL_UNICODE effects. |
|
49
|
|
|
|
|
|
|
# Pod::Simple expects to receive bytes, and we're going to return bytes. |
|
50
|
11
|
|
|
|
|
113
|
binmode($_, ':bytes') for ($in_fh, $out_fh); |
|
51
|
|
|
|
|
|
|
|
|
52
|
11
|
|
|
|
|
52
|
convert($in_fh, $out_fh); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub convert { |
|
55
|
11
|
|
|
11
|
|
36
|
my ($in_file, $out_file) = @_; |
|
56
|
11
|
|
|
|
|
161
|
my $parser = Pod::Markdown->new(%opts); |
|
57
|
11
|
|
|
|
|
99
|
$parser->output_fh($out_file); |
|
58
|
11
|
|
|
|
|
155
|
$parser->parse_file($in_file); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub get_handle { |
|
62
|
22
|
|
|
22
|
|
66
|
my ($path, $op, $default) = @_; |
|
63
|
22
|
100
|
100
|
|
|
168
|
(!defined($path) || $path eq '-') ? $default : do { |
|
64
|
16
|
50
|
|
|
|
1820
|
open(my $fh, $op, $path) |
|
65
|
|
|
|
|
|
|
or die "Failed to open '$path': $!\n"; |
|
66
|
16
|
|
|
|
|
95
|
$fh; |
|
67
|
|
|
|
|
|
|
}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |