line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Markup::Asciidoc; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
2871
|
use 5.8.1; |
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
6
|
1
|
|
|
1
|
|
6
|
use Text::Markup::Cmd; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
5
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.31'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $ASCIIDOC = find_cmd([ |
12
|
|
|
|
|
|
|
(map { (WIN32 ? ("$_.exe", "$_.bat") : ($_)) } qw(asciidoc)), |
13
|
|
|
|
|
|
|
'asciidoc.py', |
14
|
|
|
|
|
|
|
], '--version'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Arguments to pass to asciidoc. |
17
|
|
|
|
|
|
|
# Restore --safe if Asciidoc ever fixes it with the XHTML back end. |
18
|
|
|
|
|
|
|
# https://groups.google.com/forum/#!topic/asciidoc/yEr5PqHm4-o |
19
|
|
|
|
|
|
|
my @OPTIONS = qw( |
20
|
|
|
|
|
|
|
--no-header-footer |
21
|
|
|
|
|
|
|
--out-file - |
22
|
|
|
|
|
|
|
--attribute newline=\\n |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub parser { |
26
|
0
|
|
|
0
|
|
|
my ($file, $encoding, $opts) = @_; |
27
|
0
|
|
|
|
|
|
my $html = do { |
28
|
0
|
|
|
|
|
|
my $fh = open_pipe( |
29
|
|
|
|
|
|
|
$ASCIIDOC, @OPTIONS, |
30
|
|
|
|
|
|
|
'--attribute' => "encoding=$encoding", |
31
|
|
|
|
|
|
|
$file |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
binmode $fh, ":encoding($encoding)"; |
35
|
0
|
|
|
|
|
|
local $/; |
36
|
0
|
|
|
|
|
|
<$fh>; |
37
|
|
|
|
|
|
|
}; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Make sure we have something. |
40
|
0
|
0
|
|
|
|
|
return unless $html =~ /\S/; |
41
|
0
|
|
|
|
|
|
utf8::encode $html; |
42
|
0
|
0
|
|
|
|
|
return $html if { @{ $opts } }->{raw}; |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return qq{ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$html |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
__END__ |