Markup/Asciidoctor.pm

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