| 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"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | if @_ != $numargs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 954 | ▶ | bless { t => $name, c => ( @_ == 1 ? $_[0] : [@_] ) }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 900 | '$' x $numargs | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 900 | ▶ | for ( my $i = 0 ; $i < @accessors ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 795 | ▶ | my $code = @accessors == 1 ? "\$_[0]->{c}" : "\$_[0]->{c}->[$i]"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # auto-bless on access via accessor (TODO: move to constructor?) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 795 | ▶ | if ( $accessors[$i] =~ s/:\[(.+)\]$// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 3 | ▶ | croak "unknown element $name" unless $ELEMENTS{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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"
$a->{"prefix"} // []
$a->{"suffix"} // []
$a->{"mode"} // bless({"t", "NormalCitation", "c", []}, "Pandoc::Document::NormalCitation")
$a->{"num"} // 0
$a->{"hash"} // 1
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"}
Truth table50%1/2
A
A= $a->{"prefix"}
Truth table50%1/2
A
A= $a->{"suffix"}
Truth table50%1/2
A
A= $a->{"mode"}
Truth table50%1/2
A
A= $a->{"num"}
Truth table50%1/2
A
A= $a->{"hash"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 12 | my $ast = eval { decode_json( $_[0] ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 12 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | $@ =~ s/ at [^ ]+Elements\.pm line \d+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | chomp $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | croak $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 11 | ▶ | return unless reftype $ast; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 11 | ▶ | if ( reftype $ast eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition100%3/3
$selector =~ s/^([a-z]+)\s*//i and lc $1 ne lc $self->name
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | # type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 11 | ▶ | if ( $selector =~ s/^:(document|block|inline|meta)\s*// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 4 | my $method = "is_$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | return 0 unless $self->$method; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | ▶ | return 1 if $selector eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # id and/or classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | ▶ | return 0 unless $self->can('match_attributes'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 10 | ▶ | if ( $selector =~ s/^#($IDENTIFIER)\s*// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | ▶ | return 0 unless $self->id eq $1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | elsif ( $selector =~ s/^\.($IDENTIFIER)\s*// ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | ▶ | return 0 unless grep { $1 eq $_ } @{ $self->classes }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition66%2/3
$Pandoc::Elements::PANDOC_VERSION and $Pandoc::Elements::PANDOC_VERSION lt "1.16"
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||