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