blib/lib/Pandoc/Elements.pm

filter: Statementstmt 85.2% 231 / 271 Branchbran 92.4% 61 / 66 Conditioncond 54.1% 13 / 24 MC/DCmcdc 21.4% 3 / 14 Subroutinesub 96.4% 55 / 57 Podpod 100% 5 / 5 totaltotal 84.2% 368 / 437 CC 43 SCAR 13.1
CC
43
Cov
84%
citation
10.9
pandoc_json
8.2
match_simple
8.0
CRAP 3.7
« blib/lib/Pandoc/Walker.pm ↑ Summary blib/lib/Pod/Simple/Pandoc.pm »
1 package Pandoc::Elements;
2 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 our $VERSION = '0.17';
7  
8 15 our $PANDOC_VERSION; # a string like '1.16'
9 15 ▶$PANDOC_VERSION ||= $ENV{PANDOC_VERSION};
Condition33%1/3
$Pandoc::Elements::PANDOC_VERSION ||= $ENV{"PANDOC_VERSION"}
l!l&&r!l&&!r
0015
MC/DC0%0/2
$Pandoc::Elements::PANDOC_VERSION ||= $ENV{"PANDOC_VERSION"}
$Pandoc::Elements::PANDOC_VERSION $ENV{"PANDOC_VERSION"}
Truth table33%1/3
A ||= B
A= $Pandoc::Elements::PANDOC_VERSIONB= $ENV{"PANDOC_VERSION"}
ABresult
1X1
011
000
10  
11 15 our %ELEMENTS = (
12  
13 # BLOCK ELEMENTS
14 Plain => [ Block => 'content' ],
15 Para => [ Block => 'content' ],
16 CodeBlock => [ Block => qw(attr content) ],
17 RawBlock => [ Block => qw(format content) ],
18 BlockQuote => [ Block => 'content' ],
19 OrderedList => [ Block => qw(attr content/items) ],
20 BulletList => [ Block => 'content/items' ],
21 DefinitionList => [ Block => 'content/items:[DefinitionPair]' ],
22 Header => [ Block => qw(level attr content) ],
23 HorizontalRule => ['Block'],
24 Table => [ Block => qw(caption alignment widths headers rows) ],
25 Div => [ Block => qw(attr content) ],
26 Null => ['Block'],
27  
28 # INLINE ELEMENTS
29 Str => [ Inline => 'content' ],
30 Emph => [ Inline => 'content' ],
31 Strong => [ Inline => 'content' ],
32 Strikeout => [ Inline => 'content' ],
33 Superscript => [ Inline => 'content' ],
34 Subscript => [ Inline => 'content' ],
35 SmallCaps => [ Inline => 'content' ],
36 Quoted => [ Inline => qw(type content) ],
37 Cite => [ Inline => qw(citations content) ],
38 Code => [ Inline => qw(attr content) ],
39 Space => ['Inline'],
40 SoftBreak => ['Inline'],
41 LineBreak => ['Inline'],
42 Math => [ Inline => qw(type content) ],
43 RawInline => [ Inline => qw(format content) ],
44 Link => [ Inline => qw(attr content target) ],
45 Image => [ Inline => qw(attr content target) ],
46 Note => [ Inline => 'content' ],
47 Span => [ Inline => qw(attr content) ],
48  
49 # METADATA ELEMENTS
50 MetaBool => [ Meta => 'content' ],
51 MetaString => [ Meta => 'content' ],
52 MetaMap => [ Meta => 'content' ],
53 MetaInlines => [ Meta => 'content' ],
54 MetaList => [ Meta => 'content' ],
55 MetaBlocks => [ Meta => 'content' ],
56 );
57  
58 # type constructors
59 15 foreach (
60 qw(DefaultDelim Period OneParen TwoParens SingleQuote DoubleQuote
61 DisplayMath InlineMath AuthorInText SuppressAuthor NormalCitation
62 AlignLeft AlignRight AlignCenter AlignDefault DefaultStyle Example
63 Decimal LowerRoman UpperRoman LowerAlpha UpperAlpha)
64 )
65 {
66 330 $ELEMENTS{$_} = ['Inline'];
67 }
68  
69 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 15 ▶use JSON qw(decode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
71 15 ▶use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
72 15 ▶use Pandoc::Walker qw(walk);
Subroutine BEGIN: called CC=1 SCAR=0.0
73  
74 15 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
75 15 our @EXPORT = ( keys %ELEMENTS, qw(Document attributes citation pandoc_json) );
76 15 our @EXPORT_OK = ( @EXPORT, 'element' );
77  
78 # create constructor functions
79 15 foreach my $name ( keys %ELEMENTS ) {
80 15 ▶ no strict 'refs'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
81  
82 900 my ( $parent, @accessors ) = @{ $ELEMENTS{$name} };
83 900 my $numargs = scalar @accessors;
84 900 my $class = "Pandoc::Document::$name";
85 900 my @parents = map { "Pandoc::Document::$_" } ($parent);
86 1020 $parent = join ' ', map { "Pandoc::Document::$_" } $parent,
87 900 map { 'AttributesRole' } grep { $_ eq 'attr' } @accessors;
88  
89 900 eval "package $class; our \@ISA = qw($parent);";
90  
91 900 *{ __PACKAGE__ . "::$name" } = Scalar::Util::set_prototype(
92 sub {
93 955 ▶ croak "$name expects $numargs arguments, but given " . scalar @_
Subroutine __ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
if @_ != $numargs 1 954 955
94 if @_ != $numargs;
95 954 ▶ bless { t => $name, c => ( @_ == 1 ? $_[0] : [@_] ) }, $class;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 566 388 954
96 },
97 900 '$' x $numargs
98 );
99  
100 900 ▶ for ( my $i = 0 ; $i < @accessors ; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @accessors) 795 900 1695
101 795 ▶ my $code = @accessors == 1 ? "\$_[0]->{c}" : "\$_[0]->{c}->[$i]";
Branch: 1 branch
BranchTrueFalseTotal
@accessors == 1 ? : 285 510 795
102  
103 # auto-bless on access via accessor (TODO: move to constructor?)
104 795 ▶ if ( $accessors[$i] =~ s/:\[(.+)\]$// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($accessors[$i] =~ s/:\[(.+)\]$//) 15 780 795
105 15 $code = "[ map { bless \$_, 'Pandoc::Document::$1' } \@{$code} ]";
106 }
107 795 for ( split '/', $accessors[$i] ) {
108 1 ▶ *{ $class . "::$_" } = eval "sub { $code }";
Subroutine __ANON__: called CC=1 SCAR=1.9
109 }
110 }
111 }
112  
113 sub element {
114 3 ▶ my $name = shift;
Subroutine element: called CC=3 SCAR=11.0
Pod documented
115 15 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
116 3 ▶ croak "undefined element" unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 3 3
117 3 ▶ croak "unknown element $name" unless $ELEMENTS{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless $Pandoc::Elements::ELEMENTS{$name} 1 2 3
118 2 &$name(@_);
119 }
120  
121 sub Document($$) {
122 23 ▶ @_ == 2 or croak "Document expects 2 arguments, but given " . scalar @_;
Subroutine Document: called CC=2 SCAR=7.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 or croak('Document expects 2 arguments, but given ' . scalar(@_)) 0 23 23
123 23 return bless [ { unMeta => $_[0] }, $_[1] ], 'Pandoc::Document';
124 }
125  
126 # specific accessors
127  
128 1 ▶sub Pandoc::Document::DefinitionPair::term { $_[0]->[0] }
Subroutine term: called CC=1 SCAR=0.0
129 1 ▶sub Pandoc::Document::DefinitionPair::definitions { $_[0]->[1] }
Subroutine definitions: called CC=1 SCAR=0.0
130  
131 # additional functions
132  
133 sub attributes($) {
134 90 ▶ my ($attrs) = @_;
Subroutine attributes: called CC=4 SCAR=13.9
Pod documented
135 return [
136 defined $attrs->{id} ? $attrs->{id} : '',
137 defined $attrs->{classes} ? $attrs->{classes} : [],
138 [
139 1 map { $_ => $attrs->{$_} }
140 90 ▶ grep { $_ ne 'id' and $_ ne 'classes' }
Branch: 3 branches
BranchTrueFalseTotal
defined $attrs->{'id'} ? : 4 86 90
defined $attrs->{'classes'} ? : 5 85 90
$_ ne "id" and $_ ne "classes" 6 4 10
141 keys %$attrs
142 ]
143 ];
144 }
145  
146 sub citation($) {
147 1 ▶ my $a = shift;
Subroutine citation: called CC=7 SCAR=23.8
Pod documented
148 {
149 citationId => $a->{id} // "missing",
150 citationPrefix => $a->{prefix} // [],
151 citationSuffix => $a->{suffix} // [],
152 citationMode => $a->{mode} // bless(
153 { t => 'NormalCitation', c => [] },
154 'Pandoc::Document::NormalCitation'
155 ),
156 citationNoteNum => $a->{num} // 0,
157 1 ▶ citationHash => $a->{hash} // 1,
Condition50%6/12
$a->{"id"} // "missing"
l!l
10
$a->{"prefix"} // []
l!l
10
$a->{"suffix"} // []
l!l
10
$a->{"mode"} // bless({"t", "NormalCitation", "c", []}, "Pandoc::Document::NormalCitation")
l!l
01
$a->{"num"} // 0
l!l
01
$a->{"hash"} // 1
l!l
01
MC/DC0%0/1
$a->{"id"} // "missing"
$a->{"id"}
MC/DC0%0/1
$a->{"prefix"} // []
$a->{"prefix"}
MC/DC0%0/1
$a->{"suffix"} // []
$a->{"suffix"}
MC/DC0%0/1
$a->{"mode"} // bless({"t", "NormalCitation", "c", []}, "Pandoc::Document::NormalCitation")
$a->{"mode"}
MC/DC0%0/1
$a->{"num"} // 0
$a->{"num"}
MC/DC0%0/1
$a->{"hash"} // 1
$a->{"hash"}
Truth table50%1/2
A
A= $a->{"id"}
Aresult
11
00
Truth table50%1/2
A
A= $a->{"prefix"}
Aresult
11
00
Truth table50%1/2
A
A= $a->{"suffix"}
Aresult
11
00
Truth table50%1/2
A
A= $a->{"mode"}
Aresult
11
00
Truth table50%1/2
A
A= $a->{"num"}
Aresult
11
00
Truth table50%1/2
A
A= $a->{"hash"}
Aresult
11
00
158 };
159 }
160  
161 sub pandoc_json($) {
162 state $ast_to_element = sub { # compile once, use repeatedly, keep private
163 95 ▶ my $class = 'Pandoc::Document::' . $_[0]->{t};
Subroutine __ANON__: called CC=3 SCAR=11.0
164 95 ▶ if ( 'MetaMap' eq $_[0]->{t} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("MetaMap" eq $_[0]{"t"}) 2 93 95
165 2 for my $v ( values %{ $_[0]->{c} } ) {
166 5 $_[1]->($v, $_[1]);
167 }
168 }
169 95 return $class->new_from_ast($_[0])
170 12 ▶ };
Subroutine pandoc_json: called CC=8 SCAR=21.0
Pod documented
171  
172 12 ▶ shift if $_[0] =~ /^Pandoc::/;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /^Pandoc::/ 1 11 12
173  
174 12 my $ast = eval { decode_json( $_[0] ) };
175 12 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 1 11 12
176 1 $@ =~ s/ at [^ ]+Elements\.pm line \d+//;
177 1 chomp $@;
178 1 croak $@;
179 }
180 11 ▶ return unless reftype $ast;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::reftype($ast) 0 11 11
181  
182 11 ▶ if ( reftype $ast eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::reftype($ast) eq 'ARRAY') { } 10 1 11
elsif (builtin::reftype($ast) eq 'HASH' and $ast->{'t'}) { } 1 0 1
183 10 my $meta = $ast->[0]->{unMeta};
184 10 for my $v ( values %$meta ) {
185 5 $v = $ast_to_element->($v, $ast_to_element);
186 }
187 10 $ast = Document( $meta, $ast->[1] );
188 }
189 ▶ elsif ( reftype $ast eq 'HASH' and $ast->{t} ) {
Condition33%1/3
builtin::reftype($ast) eq "HASH" and $ast->{"t"}
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::reftype($ast) eq "HASH" and $ast->{"t"}
builtin::reftype($ast) eq "HASH" $ast->{"t"}
Truth table33%1/3
A and B
A= builtin::reftype($ast) eq "HASH"B= $ast->{"t"}
ABresult
0X0
100
111
190 # $ast = element( $ast->{t}, $ast->{c} );
191 1 $ast = $ast_to_element->($ast, $ast_to_element)
192 }
193  
194 11 walk $ast, $ast_to_element;
195  
196 11 return $ast;
197 }
198  
199 # document element packages
200  
201 {
202  
203 package Pandoc::Document;
204 15 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
205 15 our $VERSION = '0.04';
206 15 our @ISA = ('Pandoc::Document::Element');
207 6 ▶ sub TO_JSON { [ @{ $_[0] } ] }
Subroutine TO_JSON: called CC=1 SCAR=0.0
208 7 ▶ sub name { 'Document' }
Subroutine name: called CC=1 SCAR=0.0
209 9 ▶ sub meta { $_[0]->[0]->{unMeta} }
Subroutine meta: called CC=1 SCAR=0.0
210 5 ▶ sub content { $_[0]->[1] }
Subroutine content: called CC=1 SCAR=0.0
211 1 ▶ sub is_document { 1 }
Subroutine is_document: called CC=1 SCAR=0.0
212 }
213  
214 {
215  
216 15 package Pandoc::Document::Element;
217 15 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
218 15 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
219 15 our $VERSION = $Pandoc::Document::VERSION;
220 15 ▶ use JSON ();
Subroutine BEGIN: called CC=1 SCAR=0.0
221 15 ▶ use Scalar::Util qw(reftype);
Subroutine BEGIN: called CC=1 SCAR=0.0
222 15 ▶ use Pandoc::Walker ();
Subroutine BEGIN: called CC=1 SCAR=0.0
223  
224 sub to_json {
225 4 ▶ JSON->new->utf8->convert_blessed->encode( $_[0] );
Subroutine to_json: called CC=1 SCAR=0.0
226 }
227 21 ▶ sub TO_JSON { return { %{ $_[0] } } }
Subroutine TO_JSON: called CC=1 SCAR=0.0
228 1374 ▶ sub name { $_[0]->{t} }
Subroutine name: called CC=1 SCAR=0.0
229 0 ▶ sub content { $_[0]->{c} }
Subroutine content: not called CC=1 SCAR=6.9
230 1 ▶ sub is_document { 0 }
Subroutine is_document: called CC=1 SCAR=0.0
231 2 ▶ sub is_block { 0 }
Subroutine is_block: called CC=1 SCAR=0.0
232 1 ▶ sub is_inline { 0 }
Subroutine is_inline: called CC=1 SCAR=0.0
233 1 ▶ sub is_meta { 0 }
Subroutine is_meta: called CC=1 SCAR=0.0
234 15 *walk = *Pandoc::Walker::walk;
235 15 *query = *Pandoc::Walker::query;
236 15 *transform = *Pandoc::Walker::transform;
237  
238 79 ▶ sub new_from_ast { bless $_[1] => $_[0] }
Subroutine new_from_ast: called CC=1 SCAR=0.0
239  
240 sub string {
241  
242 # TODO: fix issue #4 to avoid this duplication
243 18 ▶ if ( $_[0]->name =~ /^(Str|Code|Math|MetaString)$/ ) {
Subroutine string: called CC=3 SCAR=11.2
Branch: 2 branches
BranchTrueFalseTotal
if ($_[0]->name =~ /^(Str|Code|Math|MetaString)$/) { } 2 16 18
elsif ($_[0]->name =~ /^(LineBreak|Space|MetaString)$/) { } 0 16 16
244 2 return $_[0]->content;
245 }
246 elsif ( $_[0]->name =~ /^(LineBreak|Space|MetaString)$/ ) {
247 0 return ' ';
248 }
249 join '', @{
250 16 $_[0]->query(
251 {
252 26 ▶ 'Str|Code|Math|MetaString' => sub { $_->content },
Subroutine __ANON__: called CC=1 SCAR=0.0
253 4 ▶ 'LineBreak|Space' => sub { ' ' },
Subroutine __ANON__: called CC=1 SCAR=0.0
254 }
255 16 );
256 };
257 }
258  
259 # TODO: replace by new class Pandoc::Selector with compiled code
260 sub match {
261 935 ▶ my $self = shift;
Subroutine match: called CC=3 SCAR=11.0
262 935 foreach my $selector ( split /\|/, shift ) {
263 1045 ▶ return 1 if $self->match_simple($selector);
Branch: 1 branch
BranchTrueFalseTotal
if $self->match_simple($selector) 62 983 1045
264 }
265 873 return 0;
266 }
267  
268 sub match_simple {
269 1045 ▶ my ( $self, $selector ) = @_;
Subroutine match_simple: called CC=8 SCAR=20.8
270 1045 $selector =~ s/^\s+|\s+$//g;
271  
272 # name
273 1045 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
if $selector =~ s/^([a-z]+)\s*//i and lc $1 ne lc $self->name 978 67 1045
Condition100%3/3
$selector =~ s/^([a-z]+)\s*//i and lc $1 ne lc $self->name
!ll&&!rl&&r
958978
MC/DC100%2/2
$selector =~ s/^([a-z]+)\s*//i and lc $1 ne lc $self->name
$selector =~ s/^([a-z]+)\s*//i lc $1 ne lc $self->name
Truth table100%3/3
A and B
A= $selector =~ s/^([a-z]+)\s*//iB= lc $1 ne lc $self->name
ABresult
0X0
100
111
274 if $selector =~ s/^([a-z]+)\s*//i and lc($1) ne lc( $self->name );
275 67 ▶ return 1 if $selector eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $selector eq "" 56 11 67
276  
277 # type
278 11 ▶ if ( $selector =~ s/^:(document|block|inline|meta)\s*// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($selector =~ s/^:(document|block|inline|meta)\s*//) 4 7 11
279 4 my $method = "is_$1";
280 4 ▶ return 0 unless $self->$method;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->$method 1 3 4
281 3 ▶ return 1 if $selector eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $selector eq "" 2 1 3
282 }
283  
284 # id and/or classes
285 8 ▶ return 0 unless $self->can('match_attributes');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can("match_attributes") 1 7 8
286 7 return $self->match_attributes($selector);
287 }
288  
289 }
290  
291 {
292  
293 15 package Pandoc::Document::AttributesRole;
294 15 my $IDENTIFIER = qr{\p{L}(\p{L}|[0-9_:.-])*};
295 4 ▶ sub id { $_[0]->attr->[0] }
Subroutine id: called CC=1 SCAR=0.0
296 8 ▶ sub classes { $_[0]->attr->[1] }
Subroutine classes: called CC=1 SCAR=0.0
297 1 ▶ sub class { join ' ', @{ $_[0]->classes } }
Subroutine class: called CC=1 SCAR=0.0
298  
299 sub match_attributes {
300 7 ▶ my ( $self, $selector ) = @_;
Subroutine match_attributes: called CC=6 SCAR=17.9
301 7 $selector =~ s/^\s+|\s+$//g;
302  
303 7 ▶ while ( $selector ne '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($selector ne "") 10 4 14
304 10 ▶ if ( $selector =~ s/^#($IDENTIFIER)\s*// ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($selector =~ s/^#($IDENTIFIER)\s*//) { } 3 7 10
elsif ($selector =~ s/^\.($IDENTIFIER)\s*//) { } 6 1 7
305 3 ▶ return 0 unless $self->id eq $1;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->id eq $1 1 2 3
306 }
307 elsif ( $selector =~ s/^\.($IDENTIFIER)\s*// ) {
308 6 ▶ return 0 unless grep { $1 eq $_ } @{ $self->classes };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$1 eq $_;} @{$self->classes;} 1 5 6
309 }
310 else {
311 1 return 0;
312 }
313 }
314  
315 4 return 1;
316 }
317 }
318  
319 {
320  
321 15 package Pandoc::Document::Block;
322 15 our $VERSION = $PANDOC::Document::VERSION;
323 15 our @ISA = ('Pandoc::Document::Element');
324 1 ▶ sub is_block { 1 }
Subroutine is_block: called CC=1 SCAR=0.0
325 }
326  
327 {
328  
329 15 package Pandoc::Document::Inline;
330 15 our $VERSION = $PANDOC::Document::VERSION;
331 15 our @ISA = ('Pandoc::Document::Element');
332 4 ▶ sub is_inline { 1 }
Subroutine is_inline: called CC=1 SCAR=0.0
333 }
334  
335 {
336  
337 15 package Pandoc::Document::Meta;
338 15 our $VERSION = $PANDOC::Document::VERSION;
339 15 our @ISA = ('Pandoc::Document::Element');
340 1 ▶ sub is_meta { 1 }
Subroutine is_meta: called CC=1 SCAR=0.0
341 }
342  
343 {
344  
345 15 package Pandoc::Document::LinkageRole;
346 15 our $VERSION = $PANDOC::Document::VERSION;
347  
348 15 for my $Element ( qw[ Link Image ] ) {
349 15 ▶ no strict 'refs'; #no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
350 30 unshift @{"Pandoc::Document::${Element}::ISA"}, __PACKAGE__; # no critic
351 }
352  
353 9 ▶ sub url { $_[0]->{c}->[-1][0] }
Subroutine url: called CC=1 SCAR=0.0
354 0 ▶ sub title { $_[0]->{c}->[-1][1] }
Subroutine title: not called CC=1 SCAR=6.9
355
356 sub new_from_ast {
357 16 ▶ my ($class, $ast) = @_;
Subroutine new_from_ast: called CC=2 SCAR=6.9
358 16 ▶ if ( 2 == @{ $ast->{c} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (2 == @{$ast->{"c"};}) 2 14 16
359 # prepend attributes to old-style ast
360 2 unshift @{ $ast->{c} }, ["",[],[]];
361 }
362 16 return bless $ast => $class;
363 }
364  
365 sub TO_JSON {
366 4 ▶ my ( $self ) = @_;
Subroutine TO_JSON: called CC=3 SCAR=11.0
367 4 my $ast = {%$self};
368 4 ▶ if ( $Pandoc::Elements::PANDOC_VERSION
Branch: 1 branch
BranchTrueFalseTotal
if ($Pandoc::Elements::PANDOC_VERSION and $Pandoc::Elements::PANDOC_VERSION lt "1.16") 2 2 4
Condition66%2/3
$Pandoc::Elements::PANDOC_VERSION and $Pandoc::Elements::PANDOC_VERSION lt "1.16"
!ll&&!rl&&r
022
MC/DC50%1/2
$Pandoc::Elements::PANDOC_VERSION and $Pandoc::Elements::PANDOC_VERSION lt "1.16"
$Pandoc::Elements::PANDOC_VERSION $Pandoc::Elements::PANDOC_VERSION lt "1.16"
Truth table66%2/3
A and B
A= $Pandoc::Elements::PANDOC_VERSIONB= $Pandoc::Elements::PANDOC_VERSION lt "1.16"
ABresult
0X0
100
111
369 and ($Pandoc::Elements::PANDOC_VERSION lt '1.16') )
370 {
371 # remove attributes from new-style ast
372 2 $ast->{c} = [ @{ $ast->{c} }[ 1, 2 ] ];
373 }
374 4 return $ast;
375 }
376  
377 }
378  
379 15 1;
380 __END__
« blib/lib/Pandoc/Walker.pm ↑ Summary blib/lib/Pod/Simple/Pandoc.pm »