blib/lib/Text/Markdown/Discount.pm

filter: Statementstmt 97.7% 44 / 45 Branchbran 87.5% 14 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 33.3% 1 / 3 totaltotal 91.5% 65 / 71 CC 10 SCAR 19.0
CC
10
Cov
95%
markdown
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 6.7
↑ Summary builder/MyBuilder.pm »
1 package Text::Markdown::Discount;
2  
3 8 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 require Exporter;
10  
11 8 our @ISA = qw(Exporter);
12  
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
16  
17 # This allows declaration use Text::Markdown::XS ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
19 # will save memory.
20 8 our %EXPORT_TAGS = ( 'all' => [ qw(
21 markdown
22 ) ] );
23  
24 8 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25  
26 8 our @EXPORT = qw(
27
28 );
29  
30 8 our $VERSION = '0.19';
31  
32 8 require XSLoader;
33 8 XSLoader::load('Text::Markdown::Discount', $VERSION);
34  
35 8 my %DISCOUNT_OPTION_FLAG = (
36 normal_listitem => 0x01,
37 alt_as_title => 0x02,
38 extended_attr => 0x04,
39 );
40  
41 0 ▶sub with_html5_tags {
Subroutine with_html5_tags: not called CC=1 SCAR=0.0
Pod undocumented
42 # nop, just for compatibility
43 }
44  
45 28 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
46 28 return bless {}, 'Text::Markdown::Discount';
47 }
48  
49 54 ▶sub markdown {
Subroutine markdown: called CC=10 SCAR=23.1
Pod documented
50 54 my ($self, $text, $flags) = @_;
51  
52 # Detect functional mode, and create an instance for this run..
53 54 ▶ unless (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self) 27 27 54
54 27 ▶ if ( $self ne __PACKAGE__ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self ne __PACKAGE__) { } 27 0 27
55 27 my $ob = __PACKAGE__->new();
56 # $self is text, $text is options
57 27 return $ob->markdown($self, $text, $flags);
58 }
59 else {
60 0 croak('Calling ' . $self . '->markdown (as a class method) is not supported.');
61 }
62 }
63 27 ▶ if (not defined $flags) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $flags) 16 11 27
64 16 $flags = MKD_NOHEADER()|MKD_NOPANTS()|MKD_DLEXTRA()|MKD_FENCEDCODE();
65 }
66  
67 27 ▶ if (ref $flags) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $flags) 8 19 27
68 8 ▶ croak('markdown options must be a hash reference')
Branch: 1 branch
BranchTrueFalseTotal
unless ref $flags eq "HASH" 0 8 8
69 unless ref $flags eq 'HASH';
70  
71 8 my %options = %{$flags};
72 8 my $legacy_flags = delete $options{flags};
73 8 ▶ if (not defined $legacy_flags) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $legacy_flags) 6 2 8
74 6 $legacy_flags = MKD_NOHEADER()|MKD_NOPANTS()|MKD_DLEXTRA()|MKD_FENCEDCODE();
75 }
76  
77 8 my $option_flags = 0;
78 8 for my $name (keys %DISCOUNT_OPTION_FLAG) {
79 $option_flags |= $DISCOUNT_OPTION_FLAG{$name}
80 24 ▶ if delete $options{$name};
Branch: 1 branch
BranchTrueFalseTotal
if delete $options{$name} 5 19 24
81 }
82 8 ▶ if (keys %options) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %options) 1 7 8
83 1 croak('unknown markdown option(s): ' . join(', ', sort keys %options));
84 }
85  
86 7 return _markdown_with_options($text, $legacy_flags, $option_flags);
87 }
88  
89 19 return _markdown($text, $flags);
90 }
91  
92  
93 8 1;
94 __END__
↑ Summary builder/MyBuilder.pm »