Markup/Asciidoc.pm

filter: Statementstmt 58.6% 17 / 29 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod n/a totaltotal 53.4% 23 / 43 CC 4 SCAR 15.9
CC
4
Cov
49%
parser
12.0
import
6.0
BEGIN
1.0
CRAP 4.9
« Markup/Asciidoctor.pm ↑ Summary Markup.pm »
1 package Text::Markup::Asciidoc;
2  
3 1 ▶use 5.8.1;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Text::Markup;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Text::Markup::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 our $VERSION = '0.43';
11  
12 0 ▶sub import {
Subroutine import: not called CC=2 SCAR=17.9
13 # Replace the regex if passed one.
14 0 ▶ Text::Markup->register( asciidoc => $_[1] ) if $_[1];
Branch: 1 branch
BranchTrueFalseTotal
if $_[1] 0 0 0
15 }
16  
17 my $ASCIIDOC = find_cmd([
18 (map { (WIN32 ? ("$_.exe", "$_.bat") : ($_)) } qw(asciidoc)),
19 'asciidoc.py',
20 ], '--version');
21  
22 # Arguments to pass to asciidoc.
23 # Restore --safe if Asciidoc ever fixes it with the XHTML back end.
24 # https://groups.google.com/forum/#!topic/asciidoc/yEr5PqHm4-o
25 my @OPTIONS = qw(
26 --no-header-footer
27 --out-file -
28 --attribute newline=\\n
29 );
30  
31 0 ▶sub parser {
Subroutine parser: not called CC=3 SCAR=24.8
32 0 my ($file, $encoding, $opts) = @_;
33 0 my $html = do {
34 0 my $fh = open_pipe(
35 $ASCIIDOC, @OPTIONS,
36 '--attribute' => "encoding=$encoding",
37 $file
38 );
39  
40 0 binmode $fh, ":encoding($encoding)";
41 0 local $/;
42 0 <$fh>;
43 };
44  
45 # Make sure we have something.
46 0 ▶ return unless $html =~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
unless $html =~ /\S/ 0 0 0
47 0 utf8::encode $html;
48 0 ▶ return $html if { @{ $opts } }->{raw};
Branch: 1 branch
BranchTrueFalseTotal
if {@{$opts;}}->{"raw"} 0 0 0
49 0 return qq{<html>
50 <head>
51 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
52 </head>
53 <body>
54 $html
55 </body>
56 </html>
57 };
58 }
59  
60 1;
61 __END__
« Markup/Asciidoctor.pm ↑ Summary Markup.pm »