lib/LaTeXML/Common/Config.pm

filter: Statementstmt 11.8% 51 / 432 Branchbran 0.3% 1 / 272 Conditioncond 1.2% 2 / 162 MC/DCmcdc 0.0% 0 / 89 Subroutinesub 18.7% 12 / 64 Podpod 62.5% 10 / 16 totaltotal 7.3% 76 / 1035 CC 204 SCAR 89.2
CC
204
Cov
6%
_prepare_options
15672.0
read
380.0
_obey_profile
210.0
CRAP 7449.2
« lib/LaTeXML/MathGrammar.pm ↑ Summary lib/LaTeXML/Post/MathML.pm »
1 # /=====================================================================\ #
2 # | LaTeXML::Common::Config | #
3 # | Configuration logic for LaTeXML | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> | #
10 # | Deyan Ginev <deyan.ginev@nist.gov> #_# | #
11 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
12 # \=========================================================ooo==U==ooo=/ #
13 package LaTeXML::Common::Config;
14 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 4 ▶use Getopt::Long qw(:config no_ignore_case);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 4 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 4 ▶use Pod::Find qw(pod_where);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶use LaTeXML::Util::Pathname;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 4 ▶use LaTeXML::Global;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 4 ▶use LaTeXML::Common::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 our $PROFILES_DB = {}; # Class-wide, caches all profiles that get used while the server is alive
25 4 our $is_bibtex = qr/(^literal\:\s*\@)|(\.bib$)/;
26 4 our $is_archive = qr/(^literal\:PK)|(\.zip$)/;
27  
28 sub new {
29 0 ▶ my ($class, %opts) = @_;
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
30 #TODO: How about defaults in the daemon server use case? Should we support those here?
31 # or are defaults always bad/confusing to allow?
32 0 ▶ %opts = () unless %opts;
Branch: 1 branch
BranchTrueFalseTotal
unless %opts 0 0 0
33 0 return bless { dirty => 1, opts => \%opts }, $class; }
34  
35 ###########################################
36 #### Command-line reader #####
37 ###########################################
38 sub getopt_specification {
39 4 ▶ my (%options) = @_;
Subroutine getopt_specification: called CC=7 SCAR=34.5
Pod undocumented
40 4 ▶ my $opts = $options{options} || {};
Condition50%1/2
$options{'options'} || {}
l!l
04
MC/DC0%0/1
$options{'options'} || {}
$options{'options'}
Truth table50%1/2
A
A= $options{'options'}
Aresult
11
00
41 my $spec = {
42 # Basics and Paths
43 "output=s" => \$$opts{destination},
44 "destination=s" => \$$opts{destination},
45 "log=s" => \$$opts{log},
46 4 "preload=s" => \@{ $$opts{preload} },
47 "preamble=s" => \$$opts{preamble},
48 "postamble=s" => \$$opts{postamble},
49 "base=s" => \$$opts{base},
50 4 "path=s" => \@{ $$opts{paths} },
51 0 ▶ "quiet" => sub { $$opts{verbosity}--; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
52 0 ▶ "verbose" => sub { $$opts{verbosity}++; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 "strict" => \$$opts{strict},
54 "includestyles" => \$$opts{includestyles},
55 "inputencoding=s" => \$$opts{inputencoding},
56 # Formats
57 0 ▶ "xml" => sub { $$opts{format} = 'xml'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
58 0 ▶ "tex" => sub { $$opts{format} = 'tex'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
59 0 ▶ "box" => sub { $$opts{format} = 'box'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
60 0 ▶ "bibtex" => sub { $$opts{type} = 'BibTeX'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
61 0 ▶ "noparse" => sub { $$opts{mathparse} = 'no'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
62 "format=s" => \$$opts{format},
63 "parse=s" => \$$opts{mathparse},
64 # Profiles
65 "profile=s" => \$$opts{profile},
66 "cache_key=s" => \$$opts{cache_key},
67 "mode=s" => \$$opts{profile},
68 "source=s" => \$$opts{source},
69 # Output framing
70 0 ▶ "embed" => sub { $$opts{whatsout} = 'fragment'; },
Subroutine __ANON__: not called CC=1 SCAR=6.9
71 "whatsin=s" => \$$opts{whatsin},
72 "whatsout=s" => \$$opts{whatsout},
73 # Daemon options
74 "autoflush=i" => \$$opts{input_limit},
75 "timeout=i" => \$$opts{timeout},
76 "expire=i" => \$$opts{expire},
77 "address=s" => \$$opts{address},
78 "port=i" => \$$opts{port},
79 # Post-processing
80 "post!" => \$$opts{post},
81 "validate!" => \$$opts{validate},
82 "omitdoctype!" => \$$opts{omitdoctype},
83 "numbersections!" => \$$opts{numbersections},
84 "timestamp=s" => \$$opts{timestamp},
85 # Various choices for math processing.
86 # Note: Could want OM embedded in mml annotation, too.
87 # In general, could(?) want multiple math reps within <Math>
88 # OR, multiple math reps combined with <mml:sematics>
89 # or, in fact, _other_ parallel means? (om?, omdoc? ...)
90 # So, need to separate multiple transformations from the combination.
91 # However, IF combining, then will need to support a id/ref mechanism.
92 "mathimagemagnification=f" => \$$opts{mathimagemag},
93 "linelength=i" => \$$opts{linelength},
94 "plane1!" => \$$opts{plane1},
95 "hackplane1!" => \$$opts{hackplane1},
96 0 ▶ "mathimages" => sub { _addMathFormat($opts, 'images'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
97 0 ▶ "nomathimages" => sub { _removeMathFormat($opts, 'images'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
98 0 ▶ "mathsvg" => sub { _addMathFormat($opts, 'svg'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
99 0 ▶ "nomathsvg" => sub { _removeMathFormat($opts, 'svg'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 0 ▶ "presentationmathml|pmml" => sub { _addMathFormat($opts, 'pmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
101 0 ▶ "contentmathml|cmml" => sub { _addMathFormat($opts, 'cmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 ▶ "openmath|om" => sub { _addMathFormat($opts, 'om'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
103 0 ▶ "keepXMath|xmath" => sub { _addMathFormat($opts, 'xmath'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
104 0 ▶ "nopresentationmathml|nopmml" => sub { _removeMathFormat($opts, 'pmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
105 0 ▶ "nocontentmathml|nocmml" => sub { _removeMathFormat($opts, 'cmml'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
106 0 ▶ "noopenmath|noom" => sub { _removeMathFormat($opts, 'om'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
107 0 ▶ "nokeepXMath|noxmath" => sub { _removeMathFormat($opts, 'xmath'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
108 0 ▶ "mathtex" => sub { _addMathFormat($opts, 'mathtex'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
109 0 ▶ "nomathtex" => sub { _removeMathFormat($opts, 'mathtex'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
110 0 ▶ "mathlex" => sub { _addMathFormat($opts, 'mathlex'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
111 0 ▶ "nomathlex" => sub { _removeMathFormat($opts, 'mathlex'); },
Subroutine __ANON__: not called CC=1 SCAR=6.9
112 "parallelmath!" => \$$opts{parallelmath},
113 # Some general XSLT/CSS/JavaScript options.
114 "stylesheet=s" => \$$opts{stylesheet},
115 4 "xsltparameter=s" => \@{ $$opts{xsltparameters} },
116 4 "css=s" => \@{ $$opts{css} },
117 "defaultresources!" => \$$opts{defaultresources},
118 4 "javascript=s" => \@{ $$opts{javascript} },
119 "icon=s" => \$$opts{icon},
120 # Options for broader document set processing
121 "split!" => \$$opts{split},
122 0 ▶ "splitat=s" => sub { $$opts{splitat} = $_[1];
Subroutine __ANON__: not called CC=2 SCAR=17.9
123 0 ▶ $$opts{split} = 1 unless defined $$opts{split}; },
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"split"} 0 0 0
124 0 ▶ "splitpath=s" => sub { $$opts{splitpath} = $_[1];
Subroutine __ANON__: not called CC=2 SCAR=17.9
125 0 ▶ $$opts{split} = 1 unless defined $$opts{split}; },
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"split"} 0 0 0
126 0 ▶ "splitnaming=s" => sub { $$opts{splitnaming} = $_[1];
Subroutine __ANON__: not called CC=2 SCAR=17.9
127 0 ▶ $$opts{split} = 1 unless defined $$opts{split}; },
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"split"} 0 0 0
128 "scan!" => \$$opts{scan},
129 "crossref!" => \$$opts{crossref},
130 "urlstyle=s" => \$$opts{urlstyle},
131 "navigationtoc=s" => \$$opts{navtoc},
132 "navtoc=s" => \$$opts{navtoc},
133 # Generating indices
134 "index!" => \$$opts{index},
135 "permutedindex!" => \$$opts{permutedindex},
136 "splitindex!" => \$$opts{splitindex},
137 # Generating Bibliographies
138 4 "bibliography=s" => \@{ $$opts{bibliographies} }, # TODO: Document
139 "splitbibliography!" => \$$opts{splitbibliography},
140 # Options for two phase processing
141 "prescan" => \$$opts{prescan},
142 "dbfile=s" => \$$opts{dbfile},
143 "sitedirectory=s" => \$$opts{sitedirectory},
144 "sourcedirectory=s" => \$$opts{sourcedirectory},
145 # For graphics: vaguely similar issues, but more limited.
146 # includegraphics images (eg. ps) can be converted to webimages (eg.png)
147 # picture/pstricks images can be converted to png or possibly svg.
148 "graphicimages!" => \$$opts{dographics},
149 4 "graphicsmap=s" => \@{ $$opts{graphicsmaps} },
150 "svg!" => \$$opts{svg},
151 "pictureimages!" => \$$opts{picimages},
152 # HELP
153 "comments!" => \$$opts{comments},
154 "VERSION!" => \$$opts{showversion},
155 4 "debug=s" => \@{ $$opts{debug} },
156 "documentid=s" => \$$opts{documentid},
157 "help" => \$$opts{help}
158 4 };
159 4 ▶ return ($spec, $opts) unless ($options{type} && ($options{type} eq 'keyvals'));
Branch: 1 branch
BranchTrueFalseTotal
unless $options{"type"} and $options{"type"} eq "keyvals" 4 0 4
Condition33%1/3
$options{"type"} and $options{"type"} eq "keyvals"
!ll&&!rl&&r
400
MC/DC0%0/2
$options{"type"} and $options{"type"} eq "keyvals"
$options{"type"} $options{"type"} eq "keyvals"
Truth table33%1/3
A and B
A= $options{"type"}B= $options{"type"} eq "keyvals"
ABresult
0X0
100
111
160 # Representation use case:
161 0 ▶ my $keyvals = $options{keyvals} || [];
Condition0%0/2
$options{'keyvals'} || []
l!l
00
MC/DC0%0/1
$options{'keyvals'} || []
$options{'keyvals'}
Truth table0%0/2
A
A= $options{'keyvals'}
Aresult
11
00
162 0 my $rep_spec = {}; # Representation specification
163 0 foreach my $key (keys %$spec) {
164 0 ▶ if ($key =~ /^(.+)=\w$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^(.+)=\w$/) { } 0 0 0
165 0 my $name = $1;
166 0 ▶ $$rep_spec{$key} = sub { CORE::push @$keyvals, [$name, $_[1]] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
167 } else {
168 $$rep_spec{$key} = sub {
169 0 ▶ my $ctl = $_[0]->{ctl};
Subroutine __ANON__: not called CC=2 SCAR=17.9
170 0 ▶ my $used = ($$ctl[0] ? 'no' : '') . $$ctl[1];
Branch: 1 branch
BranchTrueFalseTotal
$ctl->[0] ? : 0 0 0
171 0 CORE::push @$keyvals, [$used, undef] };
172 }
173 }
174 0 return ($rep_spec, $keyvals);
175 }
176 # TODO: Separate the keyvals scan from getopt_specification()
177 # into its own sub, using @GETOPT_KEYS entirely.
178 4 our @GETOPT_KEYS = keys %{ (getopt_specification())[0] };
179  
180 sub read {
181 0 ▶ my ($self, $argref, %read_options) = @_;
Subroutine read: not called CC=19 SCAR=59.4
Pod documented
182 0 my $opts = $$self{opts};
183 0 local @ARGV = @$argref;
184 0 my ($spec) = getopt_specification(options => $opts);
185 0 ▶ my $silent = %read_options && $read_options{silent};
Condition0%0/3
%read_options && $read_options{'silent'}
!ll&&!rl&&r
000
MC/DC0%0/2
%read_options && $read_options{'silent'}
%read_options $read_options{'silent'}
Truth table0%0/3
A && B
A= %read_optionsB= $read_options{'silent'}
ABresult
0X0
100
111
186 0 my $getOptions_success = GetOptions(%{$spec});
187 0 ▶ if (!$getOptions_success && !$silent) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($getOptions_success or $silent) 0 0 0
Condition0%0/3
$getOptions_success or $silent
l!l&&r!l&&!r
000
MC/DC0%0/2
$getOptions_success or $silent
$getOptions_success $silent
Truth table0%0/3
A or B
A= $getOptions_successB= $silent
ABresult
1X1
011
000
188 0 pod2usage(-message => $LaTeXML::IDENTITY, -exitval => 1, -verbose => 99,
189 -input => pod_where({ -inc => 1 }, __PACKAGE__),
190 -sections => 'OPTION SYNOPSIS', -output => \*STDERR);
191 }
192 0 ▶ if (!$silent && $$opts{help}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $silent and $opts->{"help"}) 0 0 0
Condition0%0/3
not $silent and $opts->{"help"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $silent and $opts->{"help"}
not $silent $opts->{"help"}
Truth table0%0/3
not(A) and B
A= not $silentB= $opts->{"help"}
ABresult
0X0
100
111
193 0 pod2usage(-message => $LaTeXML::IDENTITY, -exitval => 1, -verbose => 99,
194 -input => pod_where({ -inc => 1 }, __PACKAGE__),
195 -sections => 'OPTION SYNOPSIS', output => \*STDOUT);
196 }
197  
198 # Check that options for system I/O (destination and log) are valid before wasting any time...
199 0 foreach my $IO_option (qw(destination log)) {
200 0 ▶ if ($$opts{$IO_option}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{$IO_option}) 0 0 0
201 0 $$opts{$IO_option} = pathname_canonical($$opts{$IO_option});
202 0 ▶ if (my $dir = pathname_directory($$opts{$IO_option})) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $dir = pathname_directory($opts->{$IO_option})) 0 0 0
203 0 ▶ pathname_mkdir($dir) or croak "Couldn't create $IO_option directory $dir: $!"; } } }
Branch: 1 branch
BranchTrueFalseTotal
pathname_mkdir($dir) or croak("Couldn't create $IO_option directory ${dir}: $!") 0 0 0
204 # Removed math formats are irrelevant for conversion:
205 0 delete $$opts{removed_math_formats};
206  
207 0 ▶ if ($$opts{showversion}) { print STDERR "$LaTeXML::IDENTITY\n"; exit(1); }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"showversion"}) 0 0 0
208  
209 0 ▶ $$opts{source} = $ARGV[0] unless $$opts{source};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts->{"source"} 0 0 0
210 # Special source-based guessing needs to happen here,
211 # as we won't have access to the source file/literal/resource later on:
212 0 ▶ if (!$$opts{type} || ($$opts{type} eq 'auto')) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"type"} or $opts->{"type"} eq "auto") 0 0 0
Condition0%0/3
not $opts->{"type"} or $opts->{"type"} eq "auto"
l!l&&r!l&&!r
000
MC/DC0%0/2
not $opts->{"type"} or $opts->{"type"} eq "auto"
not $opts->{"type"} $opts->{"type"} eq "auto"
Truth table0%0/3
not(A) or B
A= not $opts->{"type"}B= $opts->{"type"} eq "auto"
ABresult
1X1
011
000
213 0 ▶ $$opts{type} = 'BibTeX' if ($$opts{source} && ($$opts{source} =~ /$is_bibtex/)); }
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/ 0 0 0
Condition0%0/3
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
$opts->{"source"} $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
Truth table0%0/3
A and B
A= $opts->{"source"}B= $opts->{"source"} =~ /$LaTeXML::Common::Config::is_bibtex/
ABresult
0X0
100
111
214 0 ▶ if (!$$opts{whatsin}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"whatsin"}) 0 0 0
215 0 ▶ $$opts{whatsin} = 'archive' if ($$opts{source} && ($$opts{source} =~ /$is_archive/)); }
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/ 0 0 0
Condition0%0/3
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"source"} and $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
$opts->{"source"} $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
Truth table0%0/3
A and B
A= $opts->{"source"}B= $opts->{"source"} =~ /$LaTeXML::Common::Config::is_archive/
ABresult
0X0
100
111
216 0 return $getOptions_success;
217 }
218  
219 sub read_keyvals {
220 0 ▶ my ($self, $conversion_options, %read_options) = @_;
Subroutine read_keyvals: not called CC=6 SCAR=37.4
Pod undocumented
221 0 my $cmdopts = [];
222 0 ▶ while (my ($key, $value) = splice(@$conversion_options, 0, 2)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@$conversion_options, 0, 2)) 0 0 0
223 # TODO: Is skipping over empty values ever harmful? Do we have non-empty defaults anywhere?
224 0 ▶ next if (!length($value)) && (grep { /^$key\=/ } @GETOPT_KEYS);
Branch: 1 branch
BranchTrueFalseTotal
if not length $value and grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS 0 0 0
Condition0%0/3
not length $value and grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
!ll&&!rl&&r
000
MC/DC0%0/2
not length $value and grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
not length $value grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
Truth table0%0/3
not(A) and B
A= not length $valueB= grep {/^$key\=/;} @LaTeXML::Common::Config::GETOPT_KEYS
ABresult
0X0
100
111
225 0 ▶ $key = "--$key" unless $key =~ /^\-\-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^\-\-/ 0 0 0
226 0 ▶ $value = length($value) ? "=$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
length $value ? : 0 0 0
227 0 CORE::push @$cmdopts, "$key$value";
228 }
229 # Read into a Config object:
230 0 return $self->read($cmdopts, %read_options); }
231  
232 sub scan_to_keyvals {
233 0 ▶ my ($self, $argref, %read_options) = @_;
Subroutine scan_to_keyvals: not called CC=6 SCAR=37.4
Pod undocumented
234 0 local @ARGV = @$argref;
235 0 my ($spec, $keyvals) = getopt_specification(type => 'keyvals');
236 0 ▶ my $silent = %read_options && $read_options{silent};
Condition0%0/3
%read_options && $read_options{'silent'}
!ll&&!rl&&r
000
MC/DC0%0/2
%read_options && $read_options{'silent'}
%read_options $read_options{'silent'}
Truth table0%0/3
A && B
A= %read_optionsB= $read_options{'silent'}
ABresult
0X0
100
111
237 0 my $getOptions_success = GetOptions(%$spec);
238 0 ▶ if (!$getOptions_success && !$silent) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($getOptions_success or $silent) 0 0 0
Condition0%0/3
$getOptions_success or $silent
l!l&&r!l&&!r
000
MC/DC0%0/2
$getOptions_success or $silent
$getOptions_success $silent
Truth table0%0/3
A or B
A= $getOptions_successB= $silent
ABresult
1X1
011
000
239 0 pod2usage(-message => $LaTeXML::IDENTITY, -exitval => 1, -verbose => 99,
240 -input => pod_where({ -inc => 1 }, __PACKAGE__),
241 -sections => 'OPTION SYNOPSIS', -output => \*STDERR);
242 }
243 0 ▶ CORE::push @$keyvals, ['source', $ARGV[0]] if $ARGV[0];
Branch: 1 branch
BranchTrueFalseTotal
if $ARGV[0] 0 0 0
244 0 ▶ return $getOptions_success && $keyvals;
Condition0%0/3
$getOptions_success && $keyvals
!ll&&!rl&&r
000
MC/DC0%0/2
$getOptions_success && $keyvals
$getOptions_success $keyvals
Truth table0%0/3
A && B
A= $getOptions_successB= $keyvals
ABresult
0X0
100
111
245 }
246  
247 ###########################################
248 #### Options Object Hashlike API #####
249 ###########################################
250 sub get {
251 0 ▶ my ($self, $key, $value) = @_;
Subroutine get: not called CC=1 SCAR=6.9
Pod documented
252 0 return $$self{opts}{$key}; }
253  
254 sub set {
255 0 ▶ my ($self, $key, $value) = @_;
Subroutine set: not called CC=1 SCAR=6.9
Pod documented
256 0 $$self{dirty} = 1;
257 0 $$self{opts}{$key} = $value;
258 0 return; }
259  
260 sub push {
261 0 ▶ my ($self, $key, $value) = @_;
Subroutine push: not called CC=2 SCAR=17.9
Pod undocumented
262 0 $$self{dirty} = 1;
263 0 ▶ $$self{opts}{$key} = [] unless ref $$self{opts}{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"opts"}{$key} 0 0 0
264 0 CORE::push @{ $$self{opts}{$key} }, $value;
265 0 return; }
266  
267 sub delete {
268 0 ▶ my ($self, $key) = @_;
Subroutine delete: not called CC=1 SCAR=6.9
Pod documented
269 0 $$self{dirty} = 1;
270 0 delete $$self{opts}{$key};
271 0 return; }
272  
273 sub exists {
274 0 ▶ my ($self, $key) = @_;
Subroutine exists: not called CC=1 SCAR=6.9
Pod documented
275 0 return exists $$self{opts}{$key}; }
276  
277 sub defined {
278 0 ▶ my ($self, $key) = @_;
Subroutine defined: not called CC=1 SCAR=6.9
Pod undocumented
279 0 return defined $$self{opts}{$key}; }
280  
281 sub keys {
282 0 ▶ my ($self) = @_;
Subroutine keys: not called CC=1 SCAR=6.9
Pod documented
283 0 return keys %{ $$self{opts} }; }
284  
285 sub options {
286 0 ▶ my ($self) = @_;
Subroutine options: not called CC=1 SCAR=6.9
Pod documented
287 0 return $$self{opts}; }
288  
289 sub clone {
290 0 ▶ my ($self) = @_;
Subroutine clone: not called CC=1 SCAR=6.9
Pod documented
291 0 my $clone = LaTeXML::Common::Config->new(%{ $self->options });
292 0 $$clone{dirty} = $$self{dirty};
293 0 return $clone; }
294  
295 ###########################################
296 #### Option Sanity Checking #####
297 ###########################################
298  
299 # Perform all option sanity checks
300 sub check {
301 0 ▶ my ($self) = @_;
Subroutine check: not called CC=2 SCAR=17.9
Pod documented
302 0 ▶ return unless $$self{dirty};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"dirty"} 0 0 0
303 # 1. Resolve profile
304 0 $self->_obey_profile;
305 # 2. Place sane defaults where needed
306 0 return $self->_prepare_options; }
307  
308 sub _obey_profile {
309 0 ▶ my ($self) = @_;
Subroutine _obey_profile: not called CC=14 SCAR=53.5
310 0 $$self{dirty} = 1;
311 0 my $opts = $$self{opts};
312 0 ▶ my $profile = lc($$opts{profile} || 'custom');
Condition0%0/2
$opts->{'profile'} || 'custom'
l!l
00
MC/DC0%0/1
$opts->{'profile'} || 'custom'
$opts->{'profile'}
Truth table0%0/2
A
A= $opts->{'profile'}
Aresult
11
00
313 0 $profile =~ s/\.opt$//;
314 # Look at the PROFILES_DB or find a profiles file (otherwise fallback to custom)
315 0 my $profile_opts = {};
316 0 ▶ if ($profile ne 'custom') {
Branch: 1 branch
BranchTrueFalseTotal
if ($profile ne "custom") 0 0 0
317 0 ▶ if (defined $$PROFILES_DB{$profile}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $LaTeXML::Common::Config::PROFILES_DB->{$profile}) { } 0 0 0
elsif (my $file = pathname_find($profile . '.opt', 'paths', $opts->{'paths'}, 'types', scalar [], 'installation_subdir', 'resources/Profiles')) { } 0 0 0
318 0 %$profile_opts = %{ $$PROFILES_DB{$profile} };
319 } elsif (my $file = pathname_find($profile . '.opt', paths => $$opts{paths},
320 types => [], installation_subdir => 'resources/Profiles')) {
321 0 my $conf_tmp = LaTeXML::Common::Config->new;
322 0 $conf_tmp->read(_read_options_file($file));
323 0 $profile_opts = $conf_tmp->options;
324 } else {
325 # Throw an error, fallback to custom
326 0 carp("Warning:unexpected:$profile Profile $profile was not recognized, reverting to 'custom'\n");
327 0 $$opts{profile} = 'custom';
328 0 $profile = 'custom';
329 }
330 }
331 # Erase the profile, save it as cache key
332 0 delete $$opts{profile};
333 0 ▶ $$opts{cache_key} = $profile unless defined $$opts{cache_key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"cache_key"} 0 0 0
334 0 ▶ if (%$profile_opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$profile_opts) 0 0 0
335 # Merge the new options with the profile defaults:
336 0 for my $key (grep { defined $$opts{$_} } (CORE::keys %$opts)) {
337 0 ▶ if ($key =~ /^p(ath|reload)/) { # Paths and preloads get merged in
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ /^p(ath|reload)/) { } 0 0 0
338 0 ▶ $$profile_opts{$key} = [] unless defined $$profile_opts{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $profile_opts->{$key} 0 0 0
339 0 foreach my $entry (@{ $$opts{$key} }) {
340 0 my $new = 1;
341 0 foreach (@{ $$profile_opts{$key} }) {
342 0 ▶ if ($entry eq $_) { $new = 0; last; }
Branch: 1 branch
BranchTrueFalseTotal
if ($entry eq $_) 0 0 0
343 }
344 # If new to the array, push:
345 0 ▶ CORE::push(@{ $$profile_opts{$key} }, $entry) if ($new);
Branch: 1 branch
BranchTrueFalseTotal
if $new 0 0 0
346 }
347 } else { # The other options get overwritten
348 0 $$profile_opts{$key} = $$opts{$key};
349 }
350 }
351 0 %$opts = %$profile_opts; # Move back into the user options
352 }
353 0 return; }
354  
355 # TODO: Best way to throw errors when options don't work out?
356 # How about in the case of Extras::ReadOptions?
357 # Error() and Warn() would be neat, but we have to make sure STDERR is caught beforehand.
358 # Also, there is no eval() here, so we might need a softer handling of Error()s.
359 sub _prepare_options {
360 0 ▶ my ($self) = @_;
Subroutine _prepare_options: not called CC=126 SCAR=96.6
361 0 my $opts = $$self{opts};
362 #======================================================================
363 # I. Sanity check and Completion of Core options.
364 #======================================================================
365 # "safe" and semi-perlcrtic acceptable way to set DEBUG inside arbitrary modules.
366 # Note: 'LaTeXML' refers to the top-level class
367 4 ▶ { no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.2
368 0 ▶ foreach my $ltx_class (@{ $$opts{debug} || [] }) {
Branch: 1 branch
BranchTrueFalseTotal
$opts->{"debug"} or [] 0 0 0
369 0 ▶ if ($ltx_class eq 'LaTeXML') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ltx_class eq 'LaTeXML') { } 0 0 0
370 0 ${'LaTeXML::DEBUG'} = 1; }
371 else {
372 0 ${ 'LaTeXML::' . $ltx_class . '::DEBUG' } = 1; } } }
373  
374 0 ▶ $$opts{input_limit} = 100 unless defined $$opts{input_limit}; # 100 jobs until restart
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"input_limit"} 0 0 0
375 0 ▶ $$opts{timeout} = 600 unless defined $$opts{timeout}; # 10 minute timeout default
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"timeout"} 0 0 0
376 0 ▶ $$opts{expire} = 600 unless defined $$opts{expire}; # 10 minute timeout default
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"expire"} 0 0 0
377 0 ▶ $$opts{mathparse} = 'RecDescent' unless defined $$opts{mathparse};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"mathparse"} 0 0 0
378 0 ▶ $$opts{inputencoding} = "utf-8" unless defined $$opts{inputencoding};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"inputencoding"} 0 0 0
379 0 ▶ if ($$opts{mathparse} eq 'no') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"mathparse"} eq "no") 0 0 0
380 0 $$opts{mathparse} = 0;
381 0 $$opts{nomathparse} = 1; } #Backwards compatible
382 0 ▶ $$opts{verbosity} = 0 unless defined $$opts{verbosity};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"verbosity"} 0 0 0
383 0 ▶ $$opts{preload} = [] unless defined $$opts{preload};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"preload"} 0 0 0
384 0 ▶ $$opts{paths} = ['.'] unless defined $$opts{paths};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"paths"} 0 0 0
385 0 @{ $$opts{paths} } = map { pathname_canonical($_) } @{ $$opts{paths} };
386 0 foreach (('destination', 'dbfile', 'sourcedirectory', 'sitedirectory')) {
387 0 ▶ $$opts{$_} = pathname_canonical($$opts{$_}) if defined $$opts{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{$_} 0 0 0
388 }
389  
390 0 ▶ if (!defined $$opts{whatsin}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"whatsin"}) 0 0 0
391 0 ▶ if ($$opts{preamble} || $$opts{postamble}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'preamble'} or $opts->{'postamble'}) { } 0 0 0
Condition0%0/3
$opts->{"preamble"} or $opts->{"postamble"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{"preamble"} or $opts->{"postamble"}
$opts->{"preamble"} $opts->{"postamble"}
Truth table0%0/3
A or B
A= $opts->{"preamble"}B= $opts->{"postamble"}
ABresult
1X1
011
000
392 # Preamble or postamble imply a fragment whatsin
393 0 $$opts{whatsin} = 'fragment'; }
394 else { # Default input chunk is a document
395 0 $$opts{whatsin} = 'document'; } }
396 0 ▶ $$opts{type} = 'auto' unless defined $$opts{type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"type"} 0 0 0
397 0 ▶ unshift(@{ $$opts{preload} }, ('TeX.pool', 'LaTeX.pool', 'BibTeX.pool')) if ($$opts{type} eq 'BibTeX');
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"type"} eq "BibTeX" 0 0 0
398  
399 # Destination extension might indicate the format:
400 0 ▶ if ((!defined $$opts{extension}) && (defined $$opts{destination})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"extension"} and defined $opts->{"destination"}) 0 0 0
Condition0%0/3
not defined $opts->{"extension"} and defined $opts->{"destination"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts->{"extension"} and defined $opts->{"destination"}
not defined $opts->{"extension"} defined $opts->{"destination"}
Truth table0%0/3
not(A) and B
A= not defined $opts->{"extension"}B= defined $opts->{"destination"}
ABresult
0X0
100
111
401 0 ▶ if ($$opts{destination} =~ /\.([^.]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"destination"} =~ /\.([^.]+)$/) 0 0 0
402 0 $$opts{extension} = $1; } }
403 0 ▶ if ((!defined $$opts{format}) && (defined $$opts{extension})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"format"} and defined $opts->{"extension"}) 0 0 0
Condition0%0/3
not defined $opts->{"format"} and defined $opts->{"extension"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts->{"format"} and defined $opts->{"extension"}
not defined $opts->{"format"} defined $opts->{"extension"}
Truth table0%0/3
not(A) and B
A= not defined $opts->{"format"}B= defined $opts->{"extension"}
ABresult
0X0
100
111
404 0 $$opts{format} = $$opts{extension}; }
405 0 ▶ if ((!defined $$opts{extension}) && (defined $$opts{format})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"extension"} and defined $opts->{"format"}) 0 0 0
Condition0%0/3
not defined $opts->{"extension"} and defined $opts->{"format"}
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $opts->{"extension"} and defined $opts->{"format"}
not defined $opts->{"extension"} defined $opts->{"format"}
Truth table0%0/3
not(A) and B
A= not defined $opts->{"extension"}B= defined $opts->{"format"}
ABresult
0X0
100
111
406 0 ▶ if ($$opts{format} =~ /^html/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($opts->{'format'} =~ /^html/) { } 0 0 0
elsif ($opts->{'format'} =~ /^xhtml/) { } 0 0 0
407 0 $$opts{extension} = 'html'; }
408 elsif ($$opts{format} =~ /^xhtml/) {
409 0 $$opts{extension} = 'xhtml'; }
410 else {
411 0 $$opts{extension} = 'xml'; } }
412 0 ▶ if (!defined $$opts{whatsout}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"whatsout"}) 0 0 0
413 0 ▶ if ((defined $$opts{extension}) && ($$opts{extension} eq 'zip')) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{'extension'} and $opts->{'extension'} eq 'zip') { } 0 0 0
Condition0%0/3
defined $opts->{"extension"} and $opts->{"extension"} eq "zip"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opts->{"extension"} and $opts->{"extension"} eq "zip"
defined $opts->{"extension"} $opts->{"extension"} eq "zip"
Truth table0%0/3
A and B
A= defined $opts->{"extension"}B= $opts->{"extension"} eq "zip"
ABresult
0X0
100
111
414 0 $$opts{whatsout} = 'archive';
415 } else {
416 0 $$opts{whatsout} = 'document';
417 } }
418 0 ▶ if ($$opts{format}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'format'}) { } 0 0 0
419 # Lower-case for sanity's sake
420 0 $$opts{format} = lc($$opts{format});
421 0 ▶ $$opts{format} = 'html5' if $$opts{format} eq 'html'; # Default is 5
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"format"} eq "html" 0 0 0
422 0 ▶ if ($$opts{format} eq 'zip') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"format"} eq "zip") 0 0 0
423 # Not encouraged! But try to produce something sensible anyway...
424 0 $$opts{format} = 'html5';
425 0 $$opts{whatsout} = 'archive';
426 }
427 0 $$opts{is_html} = ($$opts{format} =~ /^html/);
428 0 $$opts{is_xhtml} = ($$opts{format} =~ /^(xhtml5?|epub|mobi)$/);
429 0 ▶ $$opts{whatsout} = 'archive' if (($$opts{format} eq 'epub') || ($$opts{format} eq 'mobi'));
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"format"} eq "epub" or $opts->{"format"} eq "mobi" 0 0 0
Condition0%0/3
$opts->{"format"} eq "epub" or $opts->{"format"} eq "mobi"
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts->{"format"} eq "epub" or $opts->{"format"} eq "mobi"
$opts->{"format"} eq "epub" $opts->{"format"} eq "mobi"
Truth table0%0/3
A or B
A= $opts->{"format"} eq "epub"B= $opts->{"format"} eq "mobi"
ABresult
1X1
011
000
430 } else {
431 0 $$opts{format} = 'xml' # We failed to guess format in any-which-way, so XML is default
432 }
433 #======================================================================
434 # II. Sanity check and Completion of Post options.
435 #======================================================================
436 # Any post switch implies post (TODO: whew, lots of those, add them all!):
437 0 ▶ $$opts{math_formats} = [] unless defined $$opts{math_formats};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"math_formats"} 0 0 0
438 $$opts{post} = 1 if ((!defined $$opts{post}) &&
439 0 ▶ (scalar(@{ $$opts{math_formats} })
Condition0%0/5
$opts->{'format'} || ''
l!l
00
$opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
!ll&&!rl&&r
000
MC/DC0%0/1
$opts->{'format'} || ''
$opts->{'format'}
MC/DC0%0/2
$opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
$opts->{"whatsout"} $opts->{"whatsout"} ne "document"
Truth table0%0/2
A
A= $opts->{'format'}
Aresult
11
00
Truth table0%0/3
A and B
A= $opts->{"whatsout"}B= $opts->{"whatsout"} ne "document"
ABresult
0X0
100
111
440 || ($$opts{stylesheet})
441 || $$opts{is_html}
442 || $$opts{is_xhtml}
443 || (($$opts{format} || '') eq 'jats')
444 0 ▶ || ($$opts{whatsout} && ($$opts{whatsout} ne 'document'))
Branch: 1 branch
BranchTrueFalseTotal
if not defined $opts->{"post"} and scalar @{$opts->{"math_formats"};} || $opts->{"stylesheet"} || $opts->{"is_html"} || $opts->{"is_xhtml"} || ($opts->{"format"} || "") eq "jats" || $opts->{"whatsout"} && $opts->{"whatsout"} ne "document" 0 0 0
Condition0%0/18
not defined $opts->{"post"} and scalar @{$opts->{"math_formats"};} || $opts->{"stylesheet"} || $opts->{"is_html"} || $opts->{"is_xhtml"} || ($opts->{"format"} || "") eq "jats" || $opts->{"whatsout"} && $opts->{"whatsout"} ne "document"
!ll&&!rl&&r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"} or $opts->{"is_xhtml"} or ($opts->{"format"} || "") eq "jats" or $opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"} or $opts->{"is_xhtml"} or ($opts->{"format"} || "") eq "jats"
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"} or $opts->{"is_xhtml"}
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"} or $opts->{"is_html"}
l!l&&r!l&&!r
000
scalar @{$opts->{"math_formats"};} or $opts->{"stylesheet"}
l!l&&r!l&&!r
000
MC/DC0%0/7
not defined $opts->{"post"} and scalar @{$opts->{"math_formats"};} || $opts->{"stylesheet"} || $opts->{"is_html"} || $opts->{"is_xhtml"} || ($opts->{"format"} || "") eq "jats" || $opts->{"whatsout"} && $opts->{"whatsout"} ne "document"
not defined $opts->{"post"} scalar @{$opts->{"math_formats"};} $opts->{"stylesheet"} $opts->{"is_html"} $opts->{"is_xhtml"} ($opts->{"format"} || "") eq "jats" $opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
Truth table0%0/8
not(A) and B or C or D or E or F or G
A= not defined $opts->{"post"}B= scalar @{$opts->{"math_formats"};}C= $opts->{"stylesheet"}D= $opts->{"is_html"}E= $opts->{"is_xhtml"}F= ($opts->{"format"} || "") eq "jats"G= $opts->{"whatsout"} and $opts->{"whatsout"} ne "document"
ABCDEFGresult
0XXXXXX0
10000000
11XXXXX1
101XXXX1
1001XXX1
10001XX1
100001X1
10000011
445 )
446 );
447 # || ... || ... || ...
448 # $$opts{post}=0 if (defined $$opts{mathparse} && (! $$opts{mathparse})); # No-parse overrides post-processing
449 0 ▶ if ($$opts{post}) { # No need to bother if we're not post-processing
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"post"}) 0 0 0
450 # Default: scan and crossref on, other advanced off
451 0 ▶ $$opts{prescan} = undef unless defined $$opts{prescan};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"prescan"} 0 0 0
452 0 ▶ $$opts{dbfile} = undef unless defined $$opts{dbfile};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"dbfile"} 0 0 0
453 0 ▶ $$opts{scan} = 1 unless defined $$opts{scan};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"scan"} 0 0 0
454 0 ▶ $$opts{index} = 1 unless defined $$opts{index};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"index"} 0 0 0
455 0 ▶ $$opts{crossref} = 1 unless defined $$opts{crossref};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"crossref"} 0 0 0
456 $$opts{sitedirectory} = defined $$opts{sitedirectory} ? $$opts{sitedirectory}
457 : (defined $$opts{destination} ? pathname_directory($$opts{destination})
458 : (defined $$opts{dbfile} ? pathname_directory($$opts{dbfile})
459 0 ▶ : "."));
Branch: 3 branches
BranchTrueFalseTotal
defined $opts->{'sitedirectory'} ? : 0 0 0
defined $opts->{'destination'} ? : 0 0 0
defined $opts->{'dbfile'} ? : 0 0 0
460 0 ▶ $$opts{sourcedirectory} = undef unless defined $$opts{sourcedirectory};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"sourcedirectory"} 0 0 0
461 0 ▶ $$opts{numbersections} = 1 unless defined $$opts{numbersections};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"numbersections"} 0 0 0
462 0 ▶ $$opts{navtoc} = undef unless defined $$opts{numbersections};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"numbersections"} 0 0 0
463 0 ▶ $$opts{navtocstyles} = { context => 1, normal => 1, none => 1 } unless defined $$opts{navtocstyles};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"navtocstyles"} 0 0 0
464 0 ▶ $$opts{navtoc} = lc($$opts{navtoc}) if defined $$opts{navtoc};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts->{"navtoc"} 0 0 0
465 0 ▶ delete $$opts{navtoc} if ($$opts{navtoc} && ($$opts{navtoc} eq 'none'));
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"navtoc"} and $opts->{"navtoc"} eq "none" 0 0 0
Condition0%0/3
$opts->{"navtoc"} and $opts->{"navtoc"} eq "none"
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"navtoc"} and $opts->{"navtoc"} eq "none"
$opts->{"navtoc"} $opts->{"navtoc"} eq "none"
Truth table0%0/3
A and B
A= $opts->{"navtoc"}B= $opts->{"navtoc"} eq "none"
ABresult
0X0
100
111
466  
467 0 ▶ if ($$opts{navtoc}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"navtoc"}) 0 0 0
468 0 ▶ if (!$$opts{navtocstyles}->{ $$opts{navtoc} }) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"navtocstyles"}{$opts->{"navtoc"}}) 0 0 0
469 0 croak($$opts{navtoc} . " is not a recognized style of navigation TOC"); }
470 0 ▶ if (!$$opts{crossref}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"crossref"}) 0 0 0
471 0 croak("Cannot use option \"navigationtoc\" (" . $$opts{navtoc} . ") without \"crossref\""); } }
472 0 ▶ $$opts{urlstyle} = 'server' unless defined $$opts{urlstyle};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"urlstyle"} 0 0 0
473 0 ▶ $$opts{bibliographies} = [] unless defined $$opts{bibliographies};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"bibliographies"} 0 0 0
474  
475 # Validation:
476 0 ▶ $$opts{validate} = 1 unless defined $$opts{validate};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"validate"} 0 0 0
477 # Graphics:
478 0 ▶ $$opts{mathimagemag} = 1.75 unless defined $$opts{mathimagemag};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"mathimagemag"} 0 0 0
479 0 ▶ if ((defined $$opts{destination}) || ($$opts{whatsout} =~ /^archive/)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts->{"destination"} or $opts->{"whatsout"} =~ /^archive/) 0 0 0
Condition0%0/3
defined $opts->{"destination"} or $opts->{"whatsout"} =~ /^archive/
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $opts->{"destination"} or $opts->{"whatsout"} =~ /^archive/
defined $opts->{"destination"} $opts->{"whatsout"} =~ /^archive/
Truth table0%0/3
A or B
A= defined $opts->{"destination"}B= $opts->{"whatsout"} =~ /^archive/
ABresult
1X1
011
000
480 # We want the graphics enabled by default, but only when we have a destination
481 0 ▶ $$opts{dographics} = 1 unless defined $$opts{dographics};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"dographics"} 0 0 0
482 $$opts{picimages} = 1 if (($$opts{format} eq "html4") || ($$opts{format} eq "jats"))
483 0 ▶ && !defined $$opts{picimages};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"format"} eq "html4" || $opts->{"format"} eq "jats" and not defined $opts->{"picimages"} 0 0 0
Condition0%0/6
$opts->{"format"} eq "html4" || $opts->{"format"} eq "jats" and not defined $opts->{"picimages"}
!ll&&!rl&&r
000
$opts->{"format"} eq "html4" or $opts->{"format"} eq "jats"
l!l&&r!l&&!r
000
MC/DC0%0/3
$opts->{"format"} eq "html4" || $opts->{"format"} eq "jats" and not defined $opts->{"picimages"}
$opts->{"format"} eq "html4" $opts->{"format"} eq "jats" not defined $opts->{"picimages"}
Truth table0%0/5
A or B and not(C)
A= $opts->{"format"} eq "html4"B= $opts->{"format"} eq "jats"C= not defined $opts->{"picimages"}
ABCresult
00X0
1X00
0100
1X11
0111
484 }
485 # Split sanity:
486 0 ▶ if ($$opts{split}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"split"}) 0 0 0
487 0 ▶ $$opts{splitat} = 'section' unless defined $$opts{splitat};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"splitat"} 0 0 0
488 0 ▶ $$opts{splitnaming} = 'id' unless defined $$opts{splitnaming};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"splitnaming"} 0 0 0
489 $$opts{splitancestors} = {
490 0 part => [qw()],
491 chapter => [qw(part)],
492 section => [qw(part chapter)],
493 subsection => [qw(part chapter section)],
494 subsubsection => [qw(part chapter section subsection)] };
495 0 $$opts{splitback} = [qw(bibliography appendix index)];
496  
497 $$opts{splitnaming} = _checkOptionValue('--splitnaming', $$opts{splitnaming},
498 0 qw(id idrelative label labelrelative));
499 0 $$opts{splitat} = _checkOptionValue('--splitat', $$opts{splitat}, CORE::keys %{ $$opts{splitancestors} });
500 0 ▶ $$opts{splitpath} = make_splitpaths($opts, $$opts{splitat}) unless defined $$opts{splitpath}; }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"splitpath"} 0 0 0
501 # Check for appropriate combination of split, scan, prescan, dbfile, crossref
502 0 ▶ if ($$opts{split} && (!defined $$opts{destination}) && ($$opts{whatsout} !~ /^archive/)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"split"} and not defined $opts->{"destination"} and not $opts->{"whatsout"} =~ /^archive/) 0 0 0
Condition0%0/6
$opts->{"split"} and not defined $opts->{"destination"} and not $opts->{"whatsout"} =~ /^archive/
!ll&&!rl&&r
000
$opts->{"split"} and not defined $opts->{"destination"}
!ll&&!rl&&r
000
MC/DC0%0/3
$opts->{"split"} and not defined $opts->{"destination"} and not $opts->{"whatsout"} =~ /^archive/
$opts->{"split"} not defined $opts->{"destination"} not $opts->{"whatsout"} =~ /^archive/
Truth table0%0/4
A and not(B) and not(C)
A= $opts->{"split"}B= not defined $opts->{"destination"}C= not $opts->{"whatsout"} =~ /^archive/
ABCresult
0XX0
10X0
1100
1111
503 0 croak("Must supply --destination when using --split"); }
504 0 ▶ if ($$opts{prescan} && !$$opts{scan}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"prescan"} and not $opts->{"scan"}) 0 0 0
Condition0%0/3
$opts->{"prescan"} and not $opts->{"scan"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"prescan"} and not $opts->{"scan"}
$opts->{"prescan"} not $opts->{"scan"}
Truth table0%0/3
A and not(B)
A= $opts->{"prescan"}B= not $opts->{"scan"}
ABresult
0X0
100
111
505 0 croak("Makes no sense to --prescan with scanning disabled (--noscan)"); }
506 0 ▶ if ($$opts{prescan} && (!defined $$opts{dbfile})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"prescan"} and not defined $opts->{"dbfile"}) 0 0 0
Condition0%0/3
$opts->{"prescan"} and not defined $opts->{"dbfile"}
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"prescan"} and not defined $opts->{"dbfile"}
$opts->{"prescan"} not defined $opts->{"dbfile"}
Truth table0%0/3
A and not(B)
A= $opts->{"prescan"}B= not defined $opts->{"dbfile"}
ABresult
0X0
100
111
507 0 croak("Cannot prescan documents (--prescan) without specifying --dbfile"); }
508 0 ▶ if (!$$opts{prescan} && $$opts{crossref} && !($$opts{scan} || (defined $$opts{dbfile}))) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"prescan"} and $opts->{"crossref"} and not $opts->{"scan"} || defined $opts->{"dbfile"}) 0 0 0
Condition0%0/9
not $opts->{"prescan"} and $opts->{"crossref"} and not $opts->{"scan"} || defined $opts->{"dbfile"}
!ll&&!rl&&r
000
not $opts->{"prescan"} and $opts->{"crossref"}
!ll&&!rl&&r
000
$opts->{'scan'} || defined $opts->{'dbfile'}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $opts->{"prescan"} and $opts->{"crossref"} and not $opts->{"scan"} || defined $opts->{"dbfile"}
not $opts->{"prescan"} $opts->{"crossref"} $opts->{'scan'} defined $opts->{'dbfile'}
Truth table0%0/5
not(A) and B and not(C || D)
A= not $opts->{"prescan"}B= $opts->{"crossref"}C= $opts->{'scan'}D= defined $opts->{'dbfile'}
ABCDresult
0XXX0
10XX0
111X0
11010
11001
509 0 croak("Cannot cross-reference (--crossref) without --scan or --dbfile "); }
510 0 ▶ if ($$opts{crossref}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"crossref"}) 0 0 0
511 0 $$opts{urlstyle} = _checkOptionValue('--urlstyle', $$opts{urlstyle}, qw(server negotiated file)); }
512 0 ▶ if (($$opts{permutedindex} || $$opts{splitindex}) && (!defined $$opts{index})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"permutedindex"} || $opts->{"splitindex"} and not defined $opts->{"index"}) 0 0 0
Condition0%0/6
$opts->{"permutedindex"} || $opts->{"splitindex"} and not defined $opts->{"index"}
!ll&&!rl&&r
000
$opts->{"permutedindex"} or $opts->{"splitindex"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$opts->{"permutedindex"} || $opts->{"splitindex"} and not defined $opts->{"index"}
$opts->{"permutedindex"} $opts->{"splitindex"} not defined $opts->{"index"}
Truth table0%0/5
A or B and not(C)
A= $opts->{"permutedindex"}B= $opts->{"splitindex"}C= not defined $opts->{"index"}
ABCresult
00X0
1X00
0100
1X11
0111
513 0 $$opts{index} = 1; }
514 0 ▶ if (!$$opts{prescan} && $$opts{index} && !($$opts{scan} || defined $$opts{crossref})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"prescan"} and $opts->{"index"} and not $opts->{"scan"} || defined $opts->{"crossref"}) 0 0 0
Condition0%0/9
not $opts->{"prescan"} and $opts->{"index"} and not $opts->{"scan"} || defined $opts->{"crossref"}
!ll&&!rl&&r
000
not $opts->{"prescan"} and $opts->{"index"}
!ll&&!rl&&r
000
$opts->{'scan'} || defined $opts->{'crossref'}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $opts->{"prescan"} and $opts->{"index"} and not $opts->{"scan"} || defined $opts->{"crossref"}
not $opts->{"prescan"} $opts->{"index"} $opts->{'scan'} defined $opts->{'crossref'}
Truth table0%0/5
not(A) and B and not(C || D)
A= not $opts->{"prescan"}B= $opts->{"index"}C= $opts->{'scan'}D= defined $opts->{'crossref'}
ABCDresult
0XXX0
10XX0
111X0
11010
11001
515 0 croak("Cannot generate index (--index) without --scan or --dbfile"); }
516 0 ▶ if (!$$opts{prescan} && @{ $$opts{bibliographies} } && !($$opts{scan} || defined $$opts{crossref})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $opts->{"prescan"} and @{$opts->{"bibliographies"};} and not $opts->{"scan"} || defined $opts->{"crossref"}) 0 0 0
Condition0%0/9
not $opts->{"prescan"} and @{$opts->{"bibliographies"};} and not $opts->{"scan"} || defined $opts->{"crossref"}
!ll&&!rl&&r
000
not $opts->{"prescan"} and @{$opts->{"bibliographies"};}
!ll&&!rl&&r
000
$opts->{'scan'} || defined $opts->{'crossref'}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $opts->{"prescan"} and @{$opts->{"bibliographies"};} and not $opts->{"scan"} || defined $opts->{"crossref"}
not $opts->{"prescan"} @{$opts->{"bibliographies"};} $opts->{'scan'} defined $opts->{'crossref'}
Truth table0%0/5
not(A) and B and not(C || D)
A= not $opts->{"prescan"}B= @{$opts->{"bibliographies"};}C= $opts->{'scan'}D= defined $opts->{'crossref'}
ABCDresult
0XXX0
10XX0
111X0
11010
11001
517 0 croak("Cannot generate bibliography (--bibliography) without --scan or --dbfile"); }
518  
519 # There is now a legitimate case to preserve graphics here.
520 # if ((!defined $$opts{destination}) && ($$opts{whatsout} !~ /^archive/)
521 # && (_checkMathFormat($opts, 'images') || _checkMathFormat($opts, 'svg')
522 # || $$opts{dographics} || $$opts{picimages})) {
523 # croak("Must supply --destination unless all auxilliary file writing is disabled"
524 # . "(--nomathimages --nomathsvg --nographicimages --nopictureimages --nodefaultcss)"); }
525  
526 # Format:
527 #Default is XHTML, XML otherwise (TODO: Expand)
528 0 ▶ if (!defined $$opts{format}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $opts->{"format"}) 0 0 0
529 0 ▶ if ($$opts{stylesheet}) { $$opts{format} = "xml"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{'stylesheet'}) { } 0 0 0
530 0 else { $$opts{format} = "xhtml"; }
531 }
532  
533 0 ▶ if (!$$opts{stylesheet}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($opts->{"stylesheet"}) 0 0 0
534 0 ▶ if ($$opts{format} eq 'xhtml') { $$opts{stylesheet} = "LaTeXML-xhtml.xsl"; }
Branch: 6 branches
BranchTrueFalseTotal
if ($opts->{'format'} eq 'xhtml') { } 0 0 0
elsif ($opts->{'format'} eq 'html4') { } 0 0 0
elsif ($opts->{'format'} =~ /^epub|mobi$/) { } 0 0 0
elsif ($opts->{'format'} eq 'html5') { } 0 0 0
elsif ($opts->{'format'} eq 'jats') { } 0 0 0
elsif ($opts->{'format'} eq 'xml') { } 0 0 0
535 0 elsif ($$opts{format} eq "html4") { $$opts{stylesheet} = "LaTeXML-html4.xsl"; }
536 0 elsif ($$opts{format} =~ /^epub|mobi$/) { $$opts{stylesheet} = "LaTeXML-epub3.xsl"; }
537 0 elsif ($$opts{format} eq "html5") { $$opts{stylesheet} = "LaTeXML-html5.xsl"; }
538 0 elsif ($$opts{format} eq "jats") { $$opts{stylesheet} = "LaTeXML-jats.xsl"; }
539 0 elsif ($$opts{format} eq "xml") { delete $$opts{stylesheet}; }
540 0 else { croak("Unrecognized target format: " . $$opts{format}); }
541 }
542 # Check format and complete math and image options
543 0 ▶ if ($$opts{format} eq 'html4') {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"format"} eq "html4") 0 0 0
544 0 ▶ $$opts{svg} = 0 unless defined $$opts{svg}; # No SVG by default in HTML.
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"svg"} 0 0 0
545 0 croak("Default html4 stylesheet only supports math images, not " . join(', ', @{ $$opts{math_formats} }))
546 if (!defined $$opts{stylesheet})
547 0 ▶ && scalar(grep { $_ ne 'images' } @{ $$opts{math_formats} });
Branch: 1 branch
BranchTrueFalseTotal
if not defined $opts->{"stylesheet"} and scalar grep({$_ ne "images";} @{$$opts{"math_formats"};}) 0 0 0
Condition0%0/2
not defined $opts->{"stylesheet"} and scalar grep({$_ ne "images";} @{$$opts{"math_formats"};})
!ll
00
MC/DC0%0/1
not defined $opts->{"stylesheet"} and scalar grep({$_ ne "images";} @{$$opts{"math_formats"};})
not defined $opts->{"stylesheet"}
Truth table0%0/2
not(A)
A= not defined $opts->{"stylesheet"}
Aresult
00
11
548 0 ▶ croak("Default html stylesheet does not support svg") if $$opts{svg};
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"svg"} 0 0 0
549 0 $$opts{math_formats} = [];
550 0 _maybeAddMathFormat($opts, 'images');
551 }
552 0 ▶ $$opts{svg} = 1 unless defined $$opts{svg}; # If we're not making HTML, SVG is on by default
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"svg"} 0 0 0
553 # PMML default if we're HTMLy and all else fails and no mathimages:
554 0 ▶ if (((!defined $$opts{math_formats}) || (!scalar(@{ $$opts{math_formats} })))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $opts->{"math_formats"} && scalar @{$opts->{"math_formats"};} and $opts->{"is_html"} || $opts->{"is_xhtml"} || $opts->{"format"} eq "jats") 0 0 0
Condition0%0/12
not defined $opts->{"math_formats"} && scalar @{$opts->{"math_formats"};} and $opts->{"is_html"} || $opts->{"is_xhtml"} || $opts->{"format"} eq "jats"
!ll&&!rl&&r
000
defined $opts->{'math_formats'} && scalar @{$opts->{'math_formats'};}
!ll&&!rl&&r
000
$opts->{"is_html"} or $opts->{"is_xhtml"} or $opts->{"format"} eq "jats"
l!l&&r!l&&!r
000
$opts->{"is_html"} or $opts->{"is_xhtml"}
l!l&&r!l&&!r
000
MC/DC0%0/5
not defined $opts->{"math_formats"} && scalar @{$opts->{"math_formats"};} and $opts->{"is_html"} || $opts->{"is_xhtml"} || $opts->{"format"} eq "jats"
defined $opts->{'math_formats'} scalar @{$opts->{'math_formats'};} $opts->{"is_html"} $opts->{"is_xhtml"} $opts->{"format"} eq "jats"
Truth table0%0/9
not(A && B) and C or D or E
A= defined $opts->{'math_formats'}B= scalar @{$opts->{'math_formats'};}C= $opts->{"is_html"}D= $opts->{"is_xhtml"}E= $opts->{"format"} eq "jats"
ABCDEresult
11XXX0
0X0000
100000
0X1XX1
0X01X1
0X0011
101XX1
1001X1
100011
555 && ($$opts{is_html} || $$opts{is_xhtml} || ($$opts{format} eq 'jats'))) {
556 0 CORE::push @{ $$opts{math_formats} }, 'pmml';
557 }
558 # use parallel markup if there are multiple formats requested.
559 0 ▶ $$opts{parallelmath} = 1 if ($$opts{math_formats} && (@{ $$opts{math_formats} } > 1));
Branch: 1 branch
BranchTrueFalseTotal
if $opts->{"math_formats"} and @{$opts->{"math_formats"};} > 1 0 0 0
Condition0%0/3
$opts->{"math_formats"} and @{$opts->{"math_formats"};} > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$opts->{"math_formats"} and @{$opts->{"math_formats"};} > 1
$opts->{"math_formats"} @{$opts->{"math_formats"};} > 1
Truth table0%0/3
A and B
A= $opts->{"math_formats"}B= @{$opts->{"math_formats"};} > 1
ABresult
0X0
100
111
560 }
561 # If really nothing hints to define format, then default it to XML
562 0 ▶ $$opts{format} = 'xml' unless defined $$opts{format};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"format"} 0 0 0
563 0 $$self{dirty} = 0;
564 0 return; }
565  
566 ## Utilities:
567  
568 sub _addMathFormat {
569 0 ▶ my ($opts, $fmt) = @_;
Subroutine _addMathFormat: not called CC=4 SCAR=30.0
570 0 ▶ $$opts{math_formats} = [] unless defined $$opts{math_formats};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"math_formats"} 0 0 0
571 0 CORE::push(@{ $$opts{math_formats} }, $fmt)
572 0 ▶ unless (grep { $_ eq $fmt } @{ $$opts{math_formats} }) || $$opts{removed_math_formats}->{$fmt};
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt} 0 0 0
Condition0%0/3
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} $opts->{"removed_math_formats"}{$fmt}
Truth table0%0/3
A or B
A= grep {$_ eq $fmt;} @{$$opts{"math_formats"};}B= $opts->{"removed_math_formats"}{$fmt}
ABresult
1X1
011
000
573 0 return; }
574  
575 sub _removeMathFormat {
576 0 ▶ my ($opts, $fmt) = @_;
Subroutine _removeMathFormat: not called CC=1 SCAR=6.9
577 0 @{ $$opts{math_formats} } = grep { $_ ne $fmt } @{ $$opts{math_formats} };
578 0 $$opts{removed_math_formats}->{$fmt} = 1;
579 0 return; }
580  
581 sub _maybeAddMathFormat {
582 0 ▶ my ($opts, $fmt) = @_;
Subroutine _maybeAddMathFormat: not called CC=3 SCAR=24.8
583 0 unshift(@{ $$opts{math_formats} }, $fmt)
584 0 ▶ unless (grep { $_ eq $fmt } @{ $$opts{math_formats} }) || $$opts{removed_math_formats}{$fmt};
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt} 0 0 0
Condition0%0/3
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
l!l&&r!l&&!r
000
MC/DC0%0/2
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} or $opts->{"removed_math_formats"}{$fmt}
grep {$_ eq $fmt;} @{$$opts{"math_formats"};} $opts->{"removed_math_formats"}{$fmt}
Truth table0%0/3
A or B
A= grep {$_ eq $fmt;} @{$$opts{"math_formats"};}B= $opts->{"removed_math_formats"}{$fmt}
ABresult
1X1
011
000
585 0 return; }
586  
587 sub _checkMathFormat {
588 0 ▶ my ($opts, $fmt) = @_;
Subroutine _checkMathFormat: not called CC=1 SCAR=6.9
589 0 return grep { $_ eq $fmt } @{ $$opts{math_formats} }; }
590  
591 sub _checkOptionValue {
592 0 ▶ my ($option, $value, @choices) = @_;
Subroutine _checkOptionValue: not called CC=4 SCAR=30.0
593 0 ▶ if ($value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 0 0 0
594 0 foreach my $choice (@choices) {
595 0 ▶ return $choice if substr($choice, 0, length($value)) eq $value; } }
Branch: 1 branch
BranchTrueFalseTotal
if substr($choice, 0, length $value) eq $value 0 0 0
596 0 croak("Value for $option, $value, doesn't match " . join(', ', @choices)); }
597  
598 # Contrived xpath, since backmatter can now be at any level!
599 sub make_splitpaths {
600 0 ▶ my ($opts, $splitat) = @_;
Subroutine make_splitpaths: not called CC=4 SCAR=30.0
Pod undocumented
601 0 my @paths = ();
602 0 my $anc = $$opts{splitancestors}{$splitat};
603 0 ▶ foreach my $unit ($splitat, ($anc ? @$anc : ())) {
Branch: 1 branch
BranchTrueFalseTotal
$anc ? : 0 0 0
604 0 CORE::push(@paths, "//ltx:$unit");
605 0 foreach my $back (@{ $$opts{splitback} }) {
606 CORE::push(@paths, "//ltx:$back\["
607 . join(' or ', "preceding-sibling::ltx:$unit",
608 0 map { "parent::ltx:$_"; } @{ $$opts{splitancestors}{$unit} })
609 . "]"); } }
610 0 return join(' | ', @paths); }
611  
612 ### This is from t/lib/TestDaemon.pm and ideally belongs in Util::Pathname
613 sub _read_options_file {
614 0 ▶ my ($file) = @_;
Subroutine _read_options_file: not called CC=14 SCAR=53.5
615 0 my $opts = [];
616 0 my $OPT;
617 0 print STDERR "(Loading profile $file...";
618 0 ▶ unless (open($OPT, "<", $file)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (open $OPT, "<", $file) 0 0 0
619 0 Error('expected', $file, "Could not open options file '$file'");
620 0 return; }
621 0 ▶ while (my $line = <$OPT>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $OPT)) 0 0 0
622 # Cleanup comments, padding on the input line.
623 0 $line =~ s/(?<!\\)#.*$//; # Strip trailing comments starting w/ # (but \# is quoted)
624 0 $line =~ s/\\#/#/g; # unslashify any \#
625 0 $line =~ s/^\s+//; # Trim leading & trailing whitespace
626 0 $line =~ s/\s+$//;
627 0 ▶ next unless $line; # if line isn't empty, after that.....
Branch: 1 branch
BranchTrueFalseTotal
unless $line 0 0 0
628 0 chomp($line);
629 0 ▶ if ($line =~ /(\S+)\s*=\s*(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /(\S+)\s*=\s*(.*)/) { } 0 0 0
630 0 ▶ my ($key, $value) = ($1, $2 || '');
Condition0%0/2
$2 || ''
l!l
00
MC/DC0%0/1
$2 || ''
$2
Truth table0%0/2
A
A= $2
Aresult
11
00
631 0 $value =~ s/\s+$//;
632 # Special treatment for --path=$env:
633 0 ▶ if ($value =~ /^\$(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\$(.+)$/) { } 0 0 0
634 0 my @values = ();
635 0 my $env_name = $1;
636 0 my $env_value;
637 # Allow $env/foo paths, starting with $env prefixes
638 0 ▶ if ($env_name =~ /^([^\/]+)(\/+)(.+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env_name =~ m[^([^/]+)(/+)(.+)$]) { } 0 0 0
639 0 my $trailer = $3;
640 0 ▶ if (my $env_path = $ENV{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $env_path = $ENV{$1}) 0 0 0
641 0 ▶ $env_path .= '/' unless $env_path =~ /\/$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $env_path =~ m[/$] 0 0 0
642 0 CORE::push @values, $env_path . $trailer; } }
643 else {
644 # But also the standard behaviour, where the $env is an array of paths
645 0 $env_value = $ENV{$env_name};
646 0 ▶ next unless $env_value;
Branch: 1 branch
BranchTrueFalseTotal
unless $env_value 0 0 0
647 0 @values = grep { -d $_ } reverse(split(':', $env_value));
648 0 ▶ next unless @values; }
Branch: 1 branch
BranchTrueFalseTotal
unless @values 0 0 0
649 0 CORE::push(@$opts, "--$key=$_") foreach (@values); }
650 else {
651 0 ▶ $value = $value ? "=$value" : '';
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
652 0 CORE::push @$opts, "--$key" . $value; } }
653 else {
654 0 Warning('unexpected', $line, undef,
655 "Unrecognized configuration data '$line'"); }
656 }
657 0 close $OPT;
658 0 print STDERR " )\n";
659 0 return $opts; }
660  
661 4 1;
662  
663 __END__
« lib/LaTeXML/MathGrammar.pm ↑ Summary lib/LaTeXML/Post/MathML.pm »